From f6543e83903f24687c0194783c50ceeada38058a Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 24 May 2016 06:10:27 -0400 Subject: [PATCH] fix #1083, ubuntu, diskless, enable the diskless installation log can be forwarded to the MN --- xCAT-server/lib/xcat/plugins/debian.pm | 17 +- .../share/xcat/netboot/ubuntu/genimage | 212 ++++++++++-------- 2 files changed, 126 insertions(+), 103 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 44f54b0ad..4610c6ca0 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -1431,16 +1431,17 @@ sub mknetboot } - if($::XCATSITEVALS{xcatdebugmode} eq "1"){ + if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { - my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); - if($ipaddr){ - $kcmdline .=" LOGSERVER=$ipaddr "; - }else{ - $kcmdline .=" LOGSERVER=$xcatmaster "; - } + my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); + if ($ipaddr) { + $kcmdline .=" LOGSERVER=$ipaddr "; + } + else { + $kcmdline .=" LOGSERVER=$xcatmaster "; + } - $kcmdline .= " xcatdebugmode=1 "; + $kcmdline .= " xcatdebugmode=$::XCATSITEVALS{xcatdebugmode} "; } diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index efbdb4e52..1a18df1b1 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -998,15 +998,15 @@ NORMAL=\$RESET # over the root directory. # This function is stolen from redhat shell() { - echo '' - echo -e "\$YELLOW Entering rescue/debug init shell." - echo -e " Exit shell to continue booting.\$RESET" - \$SHELL + echo '' + echo -e "\$YELLOW Entering rescue/debug init shell." + echo -e " Exit shell to continue booting.\$RESET" + \$SHELL } fancydisplay () { - clear - echo -e "\$CYAN" + clear + echo -e "\$CYAN" echo ' .. :iiii, :tLL; .,:...,. @@ -1032,8 +1032,8 @@ echo ' ;fGGGf, ,;;;;,: tf;jL, ;.:::, Powered by xCAT ,j.:; ' - echo -e "\$RESET" - echo -e "\$YELLOW" + echo -e "\$RESET" + echo -e "\$YELLOW" echo ' _________ ________________ ___ __\\_ ___ \\ / _ \\__ ___/ @@ -1042,7 +1042,7 @@ echo ' /__/\\_ \\\\______ /\\____|__ /____| \\/ \\/ \\/ ' - echo -e "\$RESET" + echo -e "\$RESET" } EOS1 @@ -1145,13 +1145,15 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATIPORT=\$VALUE + elif [ "\$KEY" = 'xcatdebugmode' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + xcatdebugmode=\$VALUE fi #if "nonodestatus" specified,do not update the nodestatus - if [ \$i == 'nonodestatus' ]; then + if [ "\$i" = 'nonodestatus' ]; then NODESTATUS='n' fi - done if [ -z "\$IFACE" ]; then @@ -1183,64 +1185,73 @@ ifconfig lo up XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` +if [ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]; then + PORT="514" + syslogd -R \$XCATMASTER:\$PORT +fi + +([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "running init script..." +([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "MASTER=\$XCATMASTER XCATIPORT=\$XCATIPORT" #update nodelist.nodestatus to "netbooting" if [ \$NODESTATUS != 'n' ]; then + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "nodestatus: netbooting,reporting..." /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" fi cd / for i in `cat /proc/cmdline`; do - KEY=`echo \$i |awk -F= '{print \$1}'` - if [ "\$KEY" == 'imgurl' ]; then - VALUE=`echo \$i |awk -F= '{print \$2}'` - if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - #NOTE needs FT retry code to scale - #NOTE: should prob have max count - FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` - - MAXTRIES=5 - ITER=0 - while [ ! -r "\$FILENAME" ]; do - echo Getting \$VALUE... - if ! /usr/bin/wget \$VALUE; then - ST=`expr \$RANDOM % 5` - sleep \$ST - rm -f \$FILENAME - ITER=\$(expr \$ITER + 1 ) - if [ "\$ITER" == "\$MAXTRIES" ]; then - /bin/busybox telnetd -l /bin/sh - shell + KEY=`echo \$i |awk -F= '{print \$1}'` + if [ "\$KEY" = 'imgurl' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + if [ "http" = "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + #NOTE needs FT retry code to scale + #NOTE: should prob have max count + FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` + + MAXTRIES=5 + ITER=0 + while [ ! -r "\$FILENAME" ]; do + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "downloading \$VALUE..." + echo Getting \$VALUE... + if ! /usr/bin/wget \$VALUE; then + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "downloading \$VALUE failed,retrying..." + ST=`expr \$RANDOM % 5` + sleep \$ST + rm -f \$FILENAME + ITER=\$(expr \$ITER + 1 ) + if [ "\$ITER" = "\$MAXTRIES" ]; then + /bin/busybox telnetd -l /bin/sh + shell + fi + fi + done + fi + if [ "nfs" = "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + NFS=1 + SERVER=`echo \$VALUE|awk -F/ '{print \$3}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=4;i<=NF;i++) printf "/%s",\$i}'` + fi + # for NFS root + elif [ "\$KEY" = 'NFSROOT' ]; then + NFSROOT=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + SERVER=`echo \$VALUE|awk -F: '{print \$1}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + elif [ "\$KEY" = 'STATEMNT' ]; then + STATELITE=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + # the VALUE may be null + if [ ! -z "\$VALUE" ]; then + SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` + SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z "\$SNAPSHOTROOT" ]; then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= fi - fi - done - fi - if [ "nfs" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - NFS=1 - SERVER=`echo \$VALUE|awk -F/ '{print \$3}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=4;i<=NF;i++) printf "/%s",\$i}'` - fi - # for NFS root - elif [ "\$KEY" == 'NFSROOT' ]; then - NFSROOT=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - SERVER=`echo \$VALUE|awk -F: '{print \$1}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - elif [ "\$KEY" == 'STATEMNT' ]; then - STATELITE=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - # the VALUE may be null - if [ ! -z \$VALUE ]; then - SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` - SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - # may be that there is not server and just a directory. - if [ -z \$SNAPSHOTROOT ] - then - SNAPSHOTROOT=\$SNAPSHOTSERVER - SNAPSHOTSERVER= - fi + fi fi - fi done # show xCAT logo @@ -1282,12 +1293,12 @@ if [ "\$STATELITE" = "1" ]; then else # for statelite mode on top of the ramdisk EOMS - print $inifile "if [ -r /rootimg-statelite.gz ]; then\n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; + print $inifile " if [ -r /rootimg-statelite.gz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { - print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT \n"; + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT \n"; } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; } print $inifile <