Index: drbl-virt/sbin/drbl_PXE_VM_create.sh
===================================================================
--- drbl-virt/sbin/drbl_PXE_VM_create.sh	(revision 178)
+++ drbl-virt/sbin/drbl_PXE_VM_create.sh	(revision 178)
@@ -0,0 +1,36 @@
+#!/bin/bash                                                                                                          
+# Program:
+#   Path DRBL evironment to support Xen/KVM
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/08/13  Rock    First release (1.0) 
+ 
+# [Source]
+source /opt/drbl-virt/conf/drbl-virt.conf
+source $Work_Path/functions_drbl_virt
+
+# [Main]
+# = 0. Variables setup =
+# == Get Host IP range/number  == #
+Host_first_IP=""
+Host_final_IP=""
+get_Host_IP_range
+# == Get VM IP range/number  == #
+VM_IP_range=""
+VM_first_IP=""
+VM_final_IP=""
+get_VM_IP_range
+
+
+# = 1. Copy VM fs =
+
+# = 2. Add NFS config =
+
+# = 3. Add DHCP config =
+
+# = 4. Add hosts and cp it to all drbl client =
+
+# = 5. generate guest config file =
Index: drbl-virt/sbin/drbl_kvm_patch.sh
===================================================================
--- drbl-virt/sbin/drbl_kvm_patch.sh	(revision 177)
+++ drbl-virt/sbin/drbl_kvm_patch.sh	(revision 178)
@@ -10,7 +10,9 @@
 
 # [Source]
-source functions_drbl_virt
 source /opt/drbl-virt/conf/drbl-virt.conf
+source $Work_Path/functions_drbl_virt
+
 # [Main]
+
 
 
Index: drbl-virt/sbin/drbl_virt.sh
===================================================================
--- drbl-virt/sbin/drbl_virt.sh	(revision 177)
+++ drbl-virt/sbin/drbl_virt.sh	(revision 178)
@@ -21,7 +21,7 @@
 # [Install VMM/Hypervisior] 1=Xen, 2=KVM
 if [ $VMM_select == 1 ]; then
-    source xen_install.sh
+    bash "xen_install.sh start"
 else
-    source kvm_install.sh
+    bash "kvm_install.sh"
 fi
 
Index: drbl-virt/sbin/drbl_xen_patch.sh
===================================================================
--- drbl-virt/sbin/drbl_xen_patch.sh	(revision 177)
+++ drbl-virt/sbin/drbl_xen_patch.sh	(revision 178)
@@ -39,9 +39,11 @@
 declare -i modify_line=$(cat -n $generate_PXE_menu | grep 'label drbl' | awk 'NR==1 {print $1}')
 # delete default
-sed -i '/^  MENU DEFAULT/d' $generate_PXE_menu
+sed -i 's/^  MENU DEFAULT/  # MENU DEFAULT/d' $generate_PXE_menu
 # modify menu
 sed -i "${modify_line}i\label drbl-virt" $generate_PXE_menu
 modify_line=$modify_line+1
 sed -i "${modify_line}i\  MENU DEFAULT" $generate_PXE_menu
+modify_line=$modify_line+1
+sed -i "${modify_line}i\  # MENU HIDE" $generate_PXE_menu
 modify_line=$modify_line+1
 sed -i "${modify_line}i\  MENU LABEL DRBL-Virtualization ($Xen, $Xen_Kernel)" $generate_PXE_menu
@@ -87,5 +89,5 @@
 NIC=""
 
-if [ \$NICs_nu -lt 1  ];
+if [ \$NICs_nu -lt 1  ]; then
     for (( i=0 ; i<\$NICs_nu ; i++ ))
     do
@@ -111,6 +113,12 @@
 sed -i "${modify_line}ibash /bin/start_xen_bridge.sh" $modify_file
 
+# = 3. enable xend xendomains daemon in DRBL Client =
+if [ -e /opt/drbl/conf/client-extra-service ]; then
+    echo 'service_extra_added="xend xendomains"' >> /opt/drbl/conf/client-extra-service
+else
+    echo 'service_extra_added="xend xendomains"' > /opt/drbl/conf/client-extra-service
+fi
 
-# = 3. Re-deploy drbl client =
+# = 4. Re-deploy drbl client =
 # == Cheange Xen Kernel ==
 echo "/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel"
@@ -123,2 +131,5 @@
 echo ""
 
+# = 5. enable xend xendomains daemon afterr drblpush =
+# /opt/drbl/sbin/drbl-client-service xend on
+
Index: drbl-virt/sbin/functions_drbl_virt
===================================================================
--- drbl-virt/sbin/functions_drbl_virt	(revision 177)
+++ drbl-virt/sbin/functions_drbl_virt	(revision 178)
@@ -142,6 +142,40 @@
 done
 
+#echo "debug: Xen_Kernel=$Xen_Kernel"
+}
 
-#echo "debug: Xen_Kernel=$Xen_Kernel"
+
+function get_Host_IP_range(){
+cat /etc/drbl/IP_HOST_TABLE | sed "${Host_first_Line}p" 
+cat /etc/drbl/IP_HOST_TABLE | sed "${Host_final_Line}p"                    
+declare -i Host_first_Line=$(cat -n /etc/drbl/IP_HOST_TABLE  | grep "# Created by DRBL (drblpush), begin" | awk '{print $1}')
+Host_first_Line=$((${Host_first_Line}+1))
+                        
+declare -i Host_final_Line=$(cat -n /etc/drbl/IP_HOST_TABLE  | grep "# Created by DRBL (drblpush), end" | awk '{print $1}')
+Host_final_Line=$((${Host_final_Line}-1))
+#echo "$Host_first_Line"
+#echo "$Host_final_Line"
+                                                                           
+Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | sed -n "${Host_first_Line}p"| awk '{print $1}')
+Host_final_IP=$(cat /etc/drbl/IP_HOST_TABLE | sed -n "${Host_final_Line}p"| awk '{print $1}')
+#echo $Host_first_IP                                                                                                                                                 
+#echo $Host_final_IP
+}
+
+function get_VM_IP_range(){
+echo ""        
+echo "Your drbl client IP range $Host_first_IP ~ $Host_final_IP"
+declare -i Host_final_IP_4=$(echo $Host_final_IP | cut -d "." -f4)
+Host_final_IP_4=$(($Host_final_IP_4+1))                       
+VM_first_IP=$(echo $Host_final_IP | cut -d "." -f 1-3)
+VM_first_IP="${VM_first_IP}.${Host_final_IP_4}"       
+echo "The VM IP Range will start from $VM_first_IP"   
+while [ $jude != "yes" -a $jude != "y" ];             
+do             
+    read "Input your IP range for VM: " VM_IP_range   
+done           
+echo "VM_first_IP=$VM_first_IP" > $Work_Home/.tmp/IP_VM_TABLE
+echo "VM_IP_range=$VM_IP_range" >> $Work_Home/.tmp/IP_VM_TABLE
+
 }
 
Index: drbl-virt/sbin/xen_install.sh
===================================================================
--- drbl-virt/sbin/xen_install.sh	(revision 177)
+++ drbl-virt/sbin/xen_install.sh	(revision 178)
@@ -50,7 +50,16 @@
             if [ $hypervisior == "Xen" ]; then
                 aptitude install xen-linux-system-2.6.26-2-xen-${Linux_bit} xen-tools bridge-utils
+                if [ $1 == "stop" ]; then
+                    update-rc.d xend remove
+                    update-rc.d xendomains remove
+                elif [ $1 == "start" ]; then
+                    update-rc.d xend defaults
+                    update-rc.d xendomains defaults
+                fi
+            
             else
                 aptitude install kvm
             fi
+
         fi  
     ;; 
