Changeset 184
- Timestamp:
- Aug 26, 2010, 2:14:50 PM (14 years ago)
- Location:
- drbl-virt/sbin
- Files:
-
- 1 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/drbl_xen_patch.sh
r178 r184 18 18 # == Shutdown all drbl client == 19 19 echo "Please check all client are shutdown !!!" 20 echo "you can use /opt/drbl/sbin/dcs to shutdown." 20 21 read -p "Push 'Enter' to continue......" 21 22 … … 33 34 34 35 # == Modify PXE booting menu == 36 # if menu doesn't has drbl-virt, then add it 37 cat /opt/drbl/sbin/generate-pxe-menu | grep drbl-virt 38 if [ $? != 0 ]; then 35 39 # backup generate-pxe-menu 36 40 cp /tftpboot/nbi_img/pxelinux.cfg/default /tftpboot/nbi_img/pxelinux.cfg/default.drbl-virt_bak 37 41 cp /opt/drbl/sbin/generate-pxe-menu /opt/drbl/sbin/generate-pxe-menu.drbl-virt_bak 42 38 43 generate_PXE_menu="/opt/drbl/sbin/generate-pxe-menu" 39 44 declare -i modify_line=$(cat -n $generate_PXE_menu | grep 'label drbl' | awk 'NR==1 {print $1}') … … 58 63 modify_line=$modify_line+1 59 64 sed -i "${modify_line}i\ " $generate_PXE_menu 60 65 fi 61 66 62 67 # = 2. Patch DRBL initrd to support bridge = 63 68 # == Patch /usr/bin/mkpxeinitrd-net (1)Xen network scripts (2)command (3)modules == 64 # backup 69 # backup mkpxeinitrd-net. if already has "drbl-virt add", dones't sed 70 cat /usr/bin/mkpxeinitrd-net | grep "drbl-virt add" 71 if [ $? != 0 ]; then 65 72 cp /usr/bin/mkpxeinitrd-net /usr/bin/mkpxeinitrd-net.drbl-virt_bak 66 73 # copy Xen network scripts … … 81 88 sed -i "${modify_line}icp -a --parents kernel/drivers/xen/netback/netloop.ko \$initrd/lib/modules/\$kernel_ver/" $modify_file 82 89 83 # == Run Xen network-bridge in booting(/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init) ==90 # == Add start_xen_bridge.sh to run Xen network-bridge (/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init) == 84 91 cat <<EOF >/usr/lib/mkpxeinitrd-net/initrd-skel/bin/start_xen_bridge.sh 85 92 #!/bin/bash … … 104 111 bash /bin/network-bridge start netdev=\$NIC 105 112 EOF 106 # backup 107 cp /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init.drbl-virt_bak 108 declare -i modify_line=$(cat -n /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init | grep "# clean the tag file" | awk '{print $1}') 109 modify_file="/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init" 113 fi 114 # == Run start_xen_bridge.sh when booting == 115 cat linuxrc-or-init | grep "bash /bin/start_xen_bridge.sh" 116 if [ $? !=0 ]; then 117 # backup linuxrc-or-init 118 cp /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init.drbl-virt_bak 119 declare -i modify_line=$(cat -n /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init | grep "# clean the tag file" | awk '{print $1}') 120 modify_file="/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init" 110 121 111 sed -i "${modify_line}i# drbl-virt add" $modify_file 112 modify_line=$modify_line+1 113 sed -i "${modify_line}ibash /bin/start_xen_bridge.sh" $modify_file 122 sed -i "${modify_line}i# drbl-virt add" $modify_file 123 modify_line=$modify_line+1 124 sed -i "${modify_line}ibash /bin/start_xen_bridge.sh" $modify_file 125 fi 126 114 127 115 128 # = 3. enable xend xendomains daemon in DRBL Client = -
drbl-virt/sbin/functions_drbl_virt
r183 r184 174 174 fi 175 175 176 # get eth network 177 eth_address=$(/opt/drbl/bin/drbl-get-ipadd $eth) 178 eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $eth) 179 eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask) 176 # get eth network X.X.X 180 177 eth_network_f3=$(echo $eth_network | cut -d "." -f 1-3) 181 178 … … 214 211 done 215 212 216 read -p "Input Prefix name for VM for $eth (ex. drblvm): " VM_prefix_name 213 #read -p "Input Prefix name for VM for $eth (ex. drblvm): " VM_prefix_name 214 VM_prefix_name=$(cat /etc/drbl/drblpush.conf | grep hostname= | sed 's/hostname=//') 217 215 read -p "Is it correct? (yes/no): " jude 218 216 done … … 238 236 VM_Host_totoal_nu=$((${Host_last_IP_4}-1+${VM_IP_range})) 239 237 if [ -e /opt/drbl-virt/etc/IP_VM_$eth ]; then 240 mv /opt/drbl-virt/etc/IP_VM_$eth /opt/drbl-virt/etc/IP_VM_${eth}.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak238 mv -f /opt/drbl-virt/etc/IP_VM_$eth /opt/drbl-virt/etc/IP_VM_${eth}.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak 241 239 fi 242 240 declare -i VM_IP_0=$VM_prefix_eth … … 275 273 echo "${eth_network_f3}.${VM_IP_1} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$eth 276 274 fi 277 278 275 done 279 276 … … 297 294 298 295 # backup 299 mv /opt/drbl-virt/etc/macadr-VM-$eth.txt /opt/drbl-virt/etc/macadr-VM-$eth.txt.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak296 mv -f /opt/drbl-virt/etc/macadr-VM-$eth.txt /opt/drbl-virt/etc/macadr-VM-$eth.txt.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak 300 297 301 298 # generate MAC … … 318 315 fi 319 316 done 320 321 322 } 323 324 317 } 318 319 function add_VM_dhcpd_conf(){ 320 # backup dhcpd.conf 321 if [ -e /etc/dhcp3/dhcpd.conf ]; then 322 cp -f /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.drbl-virt_bak 323 fi 324 325 subnet_lines=$(cat -n /etc/dhcp3/dhcpd.conf | grep $eth_network | awk '{print $1}') 326 host_lines=$(cat -n /etc/dhcp3/dhcpd.conf | grep 'host ' | grep '{' | awk '{print $1}') 327 328 for subnet_line in $subnet_lines 329 do 330 host_lines cat -n /etc/dhcp3/dhcpd.conf | sed -n "$subnet_line,\$p" | grep 'host .* {' | awk '{print $1}' 331 332 done 333 334 }
Note: See TracChangeset
for help on using the changeset viewer.