Index: /drbl-virt/install.sh
===================================================================
--- /drbl-virt/install.sh	(revision 170)
+++ /drbl-virt/install.sh	(revision 171)
@@ -12,9 +12,9 @@
 Work_Home="/opt/drbl-virt"
 Work_Path="/opt/drbl-virt/sbin"
-Now_path="pwd $0"
+Now_Path="$(dirname $0)"
 PATH=${PATH}:$Work_Path
 
 # [Source]
-source funs_drbl_virt
+source $Now_Path/sbin/functions_drbl_virt
 
 # [Main]
@@ -23,5 +23,5 @@
 
 mkdir -p $Work_Home
-cp -r $Now_path/sbin $Work_Path/
-cp -r $Now_path/conf $Work_Path/
-
+cp -fr $Now_Path/sbin $Work_Home/
+cp -fr $Now_Path/conf $Work_Home/
+cp  -fr $Now_Path/uninstall.sh $Work_Home/
Index: /drbl-virt/sbin/drbl_kvm_patch.sh
===================================================================
--- /drbl-virt/sbin/drbl_kvm_patch.sh	(revision 171)
+++ /drbl-virt/sbin/drbl_kvm_patch.sh	(revision 171)
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Program:
+#   Path DRBL evironment to support Xen/KVM
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/07/20  Rock    First release (1.0) 
+
+# [Source]
+source functions_drbl_virt
+source /opt/drbl-virt/conf/drbl-virt.conf
+# [Main]
+
+
+# [DRBL Environment Configuration]
+
Index: bl-virt/sbin/drbl_patch.sh
===================================================================
--- /drbl-virt/sbin/drbl_patch.sh	(revision 170)
+++ 	(revision )
@@ -1,28 +1,0 @@
-#!/bin/bash
-# Program:
-#   Path DRBL evironment to support Xen/KVM
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:                                                                                          
-#   2010/07/20  Rock    First release (1.0) 
-
-# [PATH]
-#Work_Path=$(dirname "$0")
-#PATH=${PATH}:$Work_Path
-
-# [Source]
-#source funs_drbl_virt
-
-# [Main]
-
-# [Install VMM/Hypervisior]
-if [ $VMM_select == 1 ]; then
-    source xen_intall.sh
-else
-    source kvm_intall.sh
-fi
-
-# [DRBL Environment Configuration]
-
Index: /drbl-virt/sbin/drbl_virt.sh
===================================================================
--- /drbl-virt/sbin/drbl_virt.sh	(revision 170)
+++ /drbl-virt/sbin/drbl_virt.sh	(revision 171)
@@ -9,12 +9,7 @@
 #   2010/07/20  Rock    First release (1.0) 
 
-# [PATH]
-Work_Home="/opt/drbl-virt"
-Work_Path="/opt/drbl-virt/sbin"
-PATH=${PATH}:$Work_Path
-
 # [Source]
-source funs_drbl_virt
-
+source /opt/drbl-virt/conf/drbl-virt.conf
+source /opt/drbl-virt/sbin/functions_drbl_virt
 # [Main]
 install_drbl-virt_dir
@@ -22,10 +17,11 @@
 check_systemInfo
 VMM_select
+#check_root
 
 # [Install VMM/Hypervisior] 1=Xen, 2=KVM
 if [ $VMM_select == 1 ]; then
-    source xen_intall.sh
+    source xen_install.sh
 else
-    source kvm_intall.sh
+    source kvm_install.sh
 fi
 
Index: bl-virt/sbin/drbl_virt_remove.sh
===================================================================
--- /drbl-virt/sbin/drbl_virt_remove.sh	(revision 170)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#!/bin/bash
-# Program:
-#  Remove DRBL virt module
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:                                                                                          
-#   2010/07/20  Rock    First release (1.0) 
-
-# [PATH]
-Work_Path=$(dirname "$0")
-PATH=${PATH}:$Work_Path
-
-# [Source]
-source funs_drbl_virt
-
-# [Main]
-check_systemInfo
-
-case $Linux_Distribution in
-    # for Ubuntu
-    "Ubuntu")
-        echo "Only support Debain"
-    ;; 
-    # for Debian
-    "Debian")
-        # check bit 
-        echo $Linux_bit | grep 64                                                                                  
-        if [ $? == 0 ]; then
-            Linux_bit="amd64"
-        else
-            Linux_bit="686"
-        fi  
-                 
-        # check version
-        echo $Linux_Version | grep "^5"
-        if [ $? == 0 ]; then
-            hypervisior=check_hypervisior
-            if [ $hypervisior == "Xen" ]; then
-                aptitude remove xen-linux-system-2.6.26-2-xen-${Linux_bit} xen-tools
-            else
-                aptitude remove kvm
-            fi
-        fi  
-    ;; 
-    # for Fedora
-    "Fedora")            
-        echo "Only support Debain"
-    ;; 
-    *) 
-        echo "Only support Debain"
-    ;; 
-esac
-
Index: /drbl-virt/sbin/drbl_xen_patch.sh
===================================================================
--- /drbl-virt/sbin/drbl_xen_patch.sh	(revision 171)
+++ /drbl-virt/sbin/drbl_xen_patch.sh	(revision 171)
@@ -0,0 +1,56 @@
+#!/bin/bash
+# Program:
+#   Path DRBL evironment to support Xen/KVM
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/07/20  Rock    First release (1.0) 
+
+# [Source]
+source functions_drbl_virt
+source /opt/drbl-virt/conf/drbl-virt.conf
+
+# [Main]
+
+# = 1. Patch DRBL xen env for client =
+# == Shutdown all drbl client ==
+echo "Please check all client are shutdown !!!"
+read -p "Push 'Enter' to continue......"
+
+# == Change xen kernel for drbl client ==
+check_xen_nu
+Xen_Kernel=$(echo $Xen_Kernel | sed 's/^vmlinuz-//g' )
+echo "/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel"
+#/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel
+echo ""
+
+# == Re-delpoy drbl client ==
+echo "Re-delpoy drbl client"
+echo "/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf"
+#/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf
+echo ""
+
+# == Copy xen image to /tftpboot/nbi_img/ ==
+echo "copy Xen image & Kernel to /tftpboot/nbi_img/"
+cp /boot/*xen* /tftpboot/nbi_img/
+cp /boot/vmlinuz-${Xen_Kernel} /tftpboot/nbi_img/
+cp /boot/initrd.img-${Xen_Kernel} /tftpboot/nbi_img/
+cp /boot/config-${Xen_Kernel} /tftpboot/nbi_img/
+echo ""
+
+# == Modify PXE booting menu ==
+# backup
+cp /tftpboot/nbi_img/pxelinux.cfg/default /tftpboot/nbi_img/pxelinux.cfg/default.drbl-virt_bak
+
+
+# = 2. Patch DRBL initrd to support bridge =
+# == Patch /usr/bin/mkpxeinitrd-net (1)modules (2)xen network scripts ==
+
+# == Copy xen netwrok scripts ==
+
+# == run xen network scripts (/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init) ==
+
+
+
Index: /drbl-virt/sbin/functions_drbl_virt
===================================================================
--- /drbl-virt/sbin/functions_drbl_virt	(revision 171)
+++ /drbl-virt/sbin/functions_drbl_virt	(revision 171)
@@ -0,0 +1,124 @@
+#!/bin/bash
+# Program:
+#   DRBL virt module
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:
+#   2010/07/20  Rock    First release (1.0)
+
+# [Variable Declation]
+cpu_flag="no"
+Linux_bit=""
+Linux_Distribution=""
+Linux_Version=""
+VMM_select=""
+
+# [Check Root]
+function check_root(){      
+  if [ $USER != "root" ]; then
+    echo -e "Please change root to run it!"
+    exit
+  fi
+} 
+
+function check_root_run(){
+    if [ $USER != "root" ]; then
+    echo -e "Please change root to run it!"
+    sudo su -c ~/"$0" "$@"
+    exit
+fi
+}
+
+
+# [Check CPU support]
+function cpu_check(){
+egrep '(vmx|svm)' --color=always /proc/cpuinfo > /dev/null
+if [ $? == 0 ]; then
+    cpu_flag="yes"
+fi
+}
+
+# [Check System Version]
+function check_systemInfo(){
+Linux_bit=$(uname -m)
+Linux_Distribution=$(lsb_release -i | awk '{print $3}')
+Linux_Version=$(lsb_release -r | awk '{print $2}')
+}
+
+# [Select Hypervisior(Xen/KVM)]
+function VMM_select(){
+if [ $cpu_flag == "yes" ]; then
+    while [ "$VMM_select" != "1" -a "$VMM_select" != "2"  ]
+    do
+       read -p "Which VMM/Hypervisior will be used in DRBL (1)Xen (2)KVM: " VMM_select
+    done
+	if [ $VMM_select == "1"  ]; then
+	  echo "Xen" > $Work_Home/.tmp/hypervisior
+	else
+	  echo "KVM" > $Work_Home/.tmp/hypervisior
+	fi	
+else
+    echo "Xen will be the only Hypervisior in your DRBL"
+    echo -e "Because CPU don't support virtualization, it can't choose KVM to be the Hypervisior"
+    echo ""
+    VMM_select=1
+    echo "Xen" > $Work_Home/.tmp/hypervisior
+fi  
+}   
+
+
+# [Create drbl-virt path]
+function install_drbl-virt_dir(){
+    mkdir -p $Work_Home/.tmp
+}
+
+
+# [Check Hypervisior]
+function check_hypervisior(){
+    hypervisior=$(cat $Work_Home/.tmp/hypervisior)    
+}
+
+
+# [Check Debian Xen package]
+function check_debian_xen(){
+aptitude update
+check_debian_xen_pkg=$(aptitude search xen-linux-system)
+if [ -n $check_debian_xen_pkg  ]; then
+    check_debian_xen_pkg="yes"
+else
+    check_debian_xen_pkg="no"
+fi
+}
+
+
+# [Check Xen kernel]
+function check_xen_nu(){
+Kernels=$(ls /boot | grep vmlinuz)
+Kernel_choose=""
+jude="no"
+
+while [ $jude != "yes" -a $jude != "y" ]
+do
+    declare -i i=1
+    echo ""
+    
+    for Kernel in $Kernels
+    do
+        echo "($i) $Kernel" 
+        i=i+1
+    done
+
+    read -p "Xen Kenrel is (1/2/...): " Kernel_choose
+    read -p "Are you sure (yes/no): " jude
+done
+
+Xen_Kernel=$(echo $Kernels | cut -d " " -f${Kernel_choose})
+#echo "debug: Xen_Kernel=$Xen_Kernel"
+}
+
+# [DRBL Check]
+
+
+
Index: bl-virt/sbin/funs_drbl_virt
===================================================================
--- /drbl-virt/sbin/funs_drbl_virt	(revision 170)
+++ 	(revision )
@@ -1,69 +1,0 @@
-#!/bin/bash
-# Program:
-#   DRBL virt module
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:
-#   2010/07/20  Rock    First release (1.0)
-
-# [Variable Declation]
-cpu_flag="no"
-Linux_bit=""
-Linux_Distribution=""
-Linux_Version=""
-VMM_select=""
-
-# [Check Root]
-function check_root(){      
-  if [ $USER != "root" ]; then
-    echo -e "Please input root password to run it!"
-    su -c "$0" "$@"                   
-
-  fi
-} 
-
-# [Check CPU support]
-function cpu_check(){
-egrep '(vmx|svm)' --color=always /proc/cpuinfo > /dev/null
-if [ $? == 0 ]; then
-    cpu_flag="yes"
-fi
-}
-
-# [Check System Version]
-function check_systemInfo(){
-Linux_bit=$(uname -m)
-Linux_Distribution=$(lsb_release -i | awk '{print $3}')
-Linux_Version=$(lsb_release -r | awk '{print $2}')
-}
-
-
-function VMM_select(){
-if [ $cpu_flag == "yes" ]; then
-    while [ "$VMM_select" != "1" -a "$VMM_select" != "2"  ]
-    do
-       read -p "Which VMM/Hypervisior will be used in DRBL (1)Xen (2)KVM: " VMM_select
-    done
-    echo "Xen" > $Work_Home/.tmp/hypervisior
-else
-    echo "Xen will be the only Hypervisior in your DRBL"
-    echo -e "Because CPU don't support virtualization, \nit can't choose KVM to be the Hypervisior"
-    VMM_select=2
-    echo "KVM" > $Work_Home/.tmp/hypervisior
-fi  
-}   
-
-# [create drbl-virt path]
-function install_drbl-virt_dir(){
-    mkdir -p $Work_Home/.tmp
-}
-
-# [check Hypervisior]
-function check_hypervisior(){
-    return $(cat $Work_Home/.tmp/hypervisior)
-}
-
-# [DRBL Check]
-
Index: /drbl-virt/sbin/kvm_install.sh
===================================================================
--- /drbl-virt/sbin/kvm_install.sh	(revision 171)
+++ /drbl-virt/sbin/kvm_install.sh	(revision 171)
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Program:
+#   DRBL virt module (kvm_install.sh)
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/07/20  Rock    First release (1.0) 
+
+# [ Intall ] 
+case $Linux_Distribution in
+    # for Ubuntu
+    "Ubuntu")
+        aptitude update ; aptitude install kvm
+    ;;
+    # for Debian
+    "Debian")
+        aptitude update ; aptitude install kvm
+    ;;
+    # for Fedora
+    "Fedora")        
+        echo "Only support Debain & Debian"
+    ;;
+    *)
+        echo "Only support Debain & Debian"
+    ;;
+esac
Index: bl-virt/sbin/kvm_intall.sh
===================================================================
--- /drbl-virt/sbin/kvm_intall.sh	(revision 170)
+++ 	(revision )
@@ -1,28 +1,0 @@
-#!/bin/bash
-# Program:
-#   DRBL virt module (kvm_install.sh)
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:                                                                                          
-#   2010/07/20  Rock    First release (1.0) 
-
-# [ Intall ] 
-case $Linux_Distribution in
-    # for Ubuntu
-    "Ubuntu")
-        aptitude update ; aptitude install kvm
-    ;;
-    # for Debian
-    "Debian")
-        aptitude update ; aptitude install kvm
-    ;;
-    # for Fedora
-    "Fedora")        
-        echo "Only support Debain & Debian"
-    ;;
-    *)
-        echo "Only support Debain & Debian"
-    ;;
-esac
Index: /drbl-virt/sbin/xen_install.sh
===================================================================
--- /drbl-virt/sbin/xen_install.sh	(revision 171)
+++ /drbl-virt/sbin/xen_install.sh	(revision 171)
@@ -0,0 +1,65 @@
+#!/bin/bash
+# Program:
+#  Remove DRBL virt module
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/07/20  Rock    First release (1.0) 
+
+# [Source]
+source /opt/drbl-virt/conf/drbl-virt.conf
+source functions_drbl_virt
+
+# [Main]
+check_systemInfo
+
+case $Linux_Distribution in
+    # for Ubuntu
+    "Ubuntu")
+        echo "Only support Debain"
+    ;; 
+    # for Debian
+    "Debian")
+        # check xen package
+        check_debian_xen_pkg=""
+        check_debian_xen
+        echo $check_debian_xen_pkg
+
+        if [ $check_debian_xen_pkg == "no" ]; then
+        echo -e "Don'f find Xen package, please check APT sources.list"
+        exit 0
+        fi
+        
+        # check bit 
+        echo $Linux_bit | grep 64 > /dev/null 
+        if [ $? == 0 ]; then
+            Linux_bit="amd64"
+        else
+            Linux_bit="686"
+        fi  
+                 
+        # check version
+        echo $Linux_Version | grep "^5" > /dev/null
+        if [ $? == 0 ]; then
+            hypervisior=""
+            check_hypervisior
+            echo $hyprtvisior
+
+            if [ $hypervisior == "Xen" ]; then
+                aptitude install xen-linux-system-2.6.26-2-xen-${Linux_bit} xen-tools bridge-utils
+            else
+                aptitude install kvm
+            fi
+        fi  
+    ;; 
+    # for Fedora
+    "Fedora")            
+        echo "Only support Debain"
+    ;; 
+    *) 
+        echo "Only support Debain"
+    ;; 
+esac
+
Index: /drbl-virt/uninstall.sh
===================================================================
--- /drbl-virt/uninstall.sh	(revision 171)
+++ /drbl-virt/uninstall.sh	(revision 171)
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Program:
+#  Remove DRBL virt module
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/07/20  Rock    First release (1.0) 
+
+# [PATH]
+Work_Home="/opt/drbl-virt"
+Work_Path="/opt/drbl-virt/sbin"
+Now_Path="$(dirname $0)"
+PATH=${PATH}:$Work_Path
+
+# [Source]
+source $Now_Path/sbin/functions_drbl_virt
+# [Main]
+check_systemInfo
+checkroot
+
+case $Linux_Distribution in
+    # for Ubuntu
+    "Ubuntu")
+        echo "Only support Debain"
+    ;; 
+    # for Debian
+    "Debian")
+        # check bit 
+        echo $Linux_bit | grep 64                                                                                  
+        if [ $? == 0 ]; then
+            Linux_bit="amd64"
+        else
+            Linux_bit="686"
+        fi  
+                 
+        # check version
+        echo $Linux_Version | grep "^5"
+        if [ $? == 0 ]; then
+            hypervisior=check_hypervisior
+            if [ $hypervisior == "Xen" ]; then
+                aptitude remove xen-linux-system-2.6.26-2-xen-${Linux_bit} xen-tools
+            else
+                aptitude remove kvm
+            fi
+        fi  
+    ;; 
+    # for Fedora
+    "Fedora")            
+        echo "Only support Debain"
+    ;; 
+    *) 
+        echo "Only support Debain"
+    ;; 
+esac
+
+cd
+rm -fr $Work_Home
