Changeset 184


Ignore:
Timestamp:
Aug 26, 2010, 2:14:50 PM (14 years ago)
Author:
rock
Message:

Modify: push arch

Location:
drbl-virt/sbin
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/drbl_xen_patch.sh

    r178 r184  
    1818# == Shutdown all drbl client ==
    1919echo "Please check all client are shutdown !!!"
     20echo "you can use /opt/drbl/sbin/dcs to shutdown."
    2021read -p "Push 'Enter' to continue......"
    2122
     
    3334
    3435# == Modify PXE booting menu ==
     36# if menu doesn't has drbl-virt, then add it
     37cat /opt/drbl/sbin/generate-pxe-menu | grep drbl-virt
     38if [  $? != 0 ]; then
    3539# backup generate-pxe-menu
    3640cp /tftpboot/nbi_img/pxelinux.cfg/default /tftpboot/nbi_img/pxelinux.cfg/default.drbl-virt_bak
    3741cp /opt/drbl/sbin/generate-pxe-menu /opt/drbl/sbin/generate-pxe-menu.drbl-virt_bak
     42
    3843generate_PXE_menu="/opt/drbl/sbin/generate-pxe-menu"
    3944declare -i modify_line=$(cat -n $generate_PXE_menu | grep 'label drbl' | awk 'NR==1 {print $1}')
     
    5863modify_line=$modify_line+1
    5964sed -i "${modify_line}i\ " $generate_PXE_menu
    60 
     65fi
    6166
    6267# = 2. Patch DRBL initrd to support bridge =
    6368# == 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
     70cat /usr/bin/mkpxeinitrd-net | grep "drbl-virt add"
     71if [ $? != 0 ]; then
    6572cp /usr/bin/mkpxeinitrd-net /usr/bin/mkpxeinitrd-net.drbl-virt_bak
    6673# copy Xen network scripts
     
    8188sed -i "${modify_line}icp -a --parents kernel/drivers/xen/netback/netloop.ko \$initrd/lib/modules/\$kernel_ver/" $modify_file
    8289
    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) ==
    8491cat <<EOF >/usr/lib/mkpxeinitrd-net/initrd-skel/bin/start_xen_bridge.sh
    8592#!/bin/bash
     
    104111bash /bin/network-bridge start netdev=\$NIC
    105112EOF
    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"
     113fi
     114# == Run start_xen_bridge.sh when booting  ==
     115cat linuxrc-or-init | grep "bash /bin/start_xen_bridge.sh"
     116if [ $? !=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"
    110121
    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
     125fi
     126
    114127
    115128# = 3. enable xend xendomains daemon in DRBL Client =
  • drbl-virt/sbin/functions_drbl_virt

    r183 r184  
    174174fi
    175175
    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
    180177eth_network_f3=$(echo $eth_network | cut -d "." -f 1-3)
    181178
     
    214211    done
    215212
    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=//')
    217215    read -p "Is it correct? (yes/no): " jude
    218216done
     
    238236VM_Host_totoal_nu=$((${Host_last_IP_4}-1+${VM_IP_range}))
    239237if [ -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_bak
     238    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
    241239fi
    242240declare -i VM_IP_0=$VM_prefix_eth
     
    275273            echo "${eth_network_f3}.${VM_IP_1} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$eth
    276274        fi
    277 
    278275    done
    279276
     
    297294
    298295# 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_bak
     296mv -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
    300297
    301298# generate MAC
     
    318315    fi
    319316done
    320 
    321 
    322 }
    323 
    324 
     317}
     318
     319function add_VM_dhcpd_conf(){
     320# backup dhcpd.conf
     321if [ -e /etc/dhcp3/dhcpd.conf ]; then
     322cp -f /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.drbl-virt_bak
     323fi
     324
     325subnet_lines=$(cat -n /etc/dhcp3/dhcpd.conf | grep $eth_network | awk '{print $1}')
     326host_lines=$(cat -n /etc/dhcp3/dhcpd.conf | grep 'host ' | grep '{' | awk '{print $1}')
     327
     328for subnet_line in $subnet_lines
     329do
     330    host_lines cat -n /etc/dhcp3/dhcpd.conf | sed -n "$subnet_line,\$p" | grep 'host .* {' | awk '{print $1}'
     331
     332done
     333
     334}
Note: See TracChangeset for help on using the changeset viewer.