Changeset 174 for drbl-virt


Ignore:
Timestamp:
Aug 11, 2010, 11:43:37 AM (14 years ago)
Author:
rock
Message:

Add: Run Xen network-bridge in initrd

File:
1 edited

Legend:

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

    r173 r174  
    2424Xen_Kernel=$(echo $Xen_Kernel | sed 's/^vmlinuz-//g' )
    2525echo "/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel"
    26 #/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel
     26/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel
    2727echo ""
    2828
     
    3030echo "Re-delpoy drbl client"
    3131echo "/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf"
    32 #/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf
     32/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf
    3333echo ""
    3434
    3535# == Copy xen image to /tftpboot/nbi_img/ ==
    3636echo "copy Xen image & Kernel to /tftpboot/nbi_img/"
    37 #cp /boot/*xen* /tftpboot/nbi_img/
    38 #cp /boot/vmlinuz-${Xen_Kernel} /tftpboot/nbi_img/
    39 #cp /boot/initrd.img-${Xen_Kernel} /tftpboot/nbi_img/
    40 #cp /boot/config-${Xen_Kernel} /tftpboot/nbi_img/
     37cp /boot/*xen* /tftpboot/nbi_img/
     38cp /boot/vmlinuz-${Xen_Kernel} /tftpboot/nbi_img/
     39cp /boot/initrd.img-${Xen_Kernel} /tftpboot/nbi_img/
     40cp /boot/config-${Xen_Kernel} /tftpboot/nbi_img/
    4141echo ""
    4242
    4343# == Modify PXE booting menu ==
    4444# backup generate-pxe-menu
    45 #cp /tftpboot/nbi_img/pxelinux.cfg/default /tftpboot/nbi_img/pxelinux.cfg/default.drbl-virt_bak
    46 #cp /opt/drbl/sbin/generate-pxe-menu /opt/drbl/sbin/generate-pxe-menu.drbl_virt_bak
     45cp /tftpboot/nbi_img/pxelinux.cfg/default /tftpboot/nbi_img/pxelinux.cfg/default.drbl-virt_bak
     46cp /opt/drbl/sbin/generate-pxe-menu /opt/drbl/sbin/generate-pxe-menu.drbl-virt_bak
    4747generate_PXE_menu="/opt/drbl/sbin/generate-pxe-menu"
    4848declare -i modify_line=$(cat -n $generate_PXE_menu | grep 'label drbl' | awk 'NR==1 {print $1}')
     
    6666
    6767# = 2. Patch DRBL initrd to support bridge =
    68 # == Patch /usr/bin/mkpxeinitrd-net (1)modules (2)xen network scripts ==
     68# == Patch /usr/bin/mkpxeinitrd-net (1)Xen network scripts (2)command (3)modules ==
     69# backup
     70cp /usr/bin/mkpxeinitrd-net /usr/bin/mkpxeinitrd-net.drbl-virt_bak
     71# copy Xen network scripts
     72cp /etc/xen/scripts/network-bridge /usr/lib/mkpxeinitrd-net/initrd-skel/bin/
     73cp /etc/xen/scripts/xen-network-common.sh /usr/lib/mkpxeinitrd-net/initrd-skel/bin/
     74cp /etc/xen/scripts/xen-script-common.sh /usr/lib/mkpxeinitrd-net/initrd-skel/bin/
     75# patch it to copy command
     76declare -i modify_line=$(cat -n /usr/bin/mkpxeinitrd-net | grep 'include_bin_prog_from_server=' | awk '{print $1}')
     77modify_file="/usr/bin/mkpxeinitrd-net"
     78sed -i "${modify_line}c\include_bin_prog_from_server='sleep lspci insmod modprobe rmmod lsmod pkill strings brctl ip egrep awk gawk seq fgrep dirname expr'" $modify_file
     79sed -i "${modify_line}i# drbl-virt add" $modify_file
     80# patch it to copy modules
     81declare -i modify_line=$(cat -n /usr/bin/mkpxeinitrd-net | grep "# Deal with firmwares" | awk '{print $1}')
     82sed -i "${modify_line}i# drbl-virt add" $modify_file
     83modify_line=$modify_line+1
     84sed -i "${modify_line}icp -a --parents kernel/net/bridge/bridge.ko \$initrd/lib/modules/\$kernel_ver/" $modify_file
     85modify_line=$modify_line+1
     86sed -i "${modify_line}icp -a --parents kernel/drivers/xen/netback/netloop.ko \$initrd/lib/modules/\$kernel_ver/" $modify_file
    6987
     88# == Run Xen network-bridge in booting (/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init) ==
     89cat <<EOF >/usr/lib/mkpxeinitrd-net/initrd-skel/bin/start_xen_bridge.sh
     90# drbl-virt add
     91NICs=$(/sbin/ifconfig | grep eth | awk '{print $1}')
     92declare -i NICs_nu=$(echo $NICs |wc -l)
     93NIC=""
    7094
    71 # == Copy xen netwrok scripts ==
     95if [ $NICs_nu -lt 1  ];
     96    for (( i=0 ; i<$NICs_nu ; i++ ))
     97    do
     98        NIC_IP=$(ifconfig eth${i} | grep "inet addr" | sed 's/inet addr://g' | sed 's/Bcast.*$//g')
     99        if [ -n $NIC_IP ]; then
     100            NIC="eth${i}"
     101            break
     102        fi
     103    done
     104else
     105    NIC=$NICS
     106fi
    72107
    73 # == run xen network scripts (/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init) ==
     108sh /bin/network-bridge start netdev=$NIC
     109EOF
     110# backup
     111cp /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init.drbl-virt_bak
     112declare -i modify_line=$(cat -n /usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init | grep "# clean the tag file" | awk '{print $1}')
     113modify_file="/usr/lib/mkpxeinitrd-net/initrd-skel/linuxrc-or-init"
    74114
    75 
    76 
     115sed -i "${modify_line}i# drbl-virt add" $modify_file
     116modify_line=$modify_line+1
     117sed -i "${modify_line}ish /bin/start_xen_bridge.sh" $modify_file
Note: See TracChangeset for help on using the changeset viewer.