From 6446fba0302e8793678fd5fdc8305b6ad3b16a4a Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 18 Aug 2015 03:28:19 -0400 Subject: [PATCH 1/2] fix defect [DEV] Error: either "dev" is duplicate, or "virbr0" is a garbage." message on the 1st reboot after kvmhost installation #86 --- xCAT/postscripts/xcatinstallpost | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index 7ad5766c0..aa92142f7 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -19,24 +19,34 @@ fi SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*10)}') sleep $SLI + MACADDR=`grep MACADDRESS= /xcatpost/mypostscript.post |awk -F = '{print $2}'|sed s/\'//g` INSTALLNIC=`ip -o link|grep -i $MACADDR|awk '{print $2}'|sed s/://` + #the nics have not been configured when running the PBS sometimes, need to make sure... RETRY=0 -until ip -4 --oneline addr show dev $INSTALLNIC|grep inet >/dev/null -do - sleep 2 - RETRY=$[ $RETRY + 1 ] - if [ $RETRY -eq 90 ];then - msgutil_r "$MASTER_IP" "err" `date`" xcatinstallpost: Network not configured, please check..." "/var/log/xcat/xcat.log" - exit 1 - fi +while true; do + #scan the nics with the specified mac address + #there will be multiple nic names for a mac address when the network bridge exists + for nic in $INSTALLNIC ;do + #check whether the nic is configured and linkup + ip -4 --oneline addr show dev $nic |grep inet >/dev/null && exit 0 + done + RETRY=$[ $RETRY + 1 ] + + if [ $RETRY -eq 90 ];then + #timeout, complain and exit + msgutil_r "$MASTER_IP" "err" `date`" xcatinstallpost: Network not configured, please check..." "/var/log/xcat/xcat.log" + exit 1 + fi + + #sleep sometime before the next scan + sleep 2 done - cd /xcatpost; PATH=/xcatpost:$PATH export PATH From 74e0d58a2010144fbcdd8aba30e9b724c236d551 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 19 Aug 2015 00:32:50 -0400 Subject: [PATCH 2/2] correct some logic in the code --- xCAT/postscripts/xcatinstallpost | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index aa92142f7..1c137854b 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -26,24 +26,28 @@ INSTALLNIC=`ip -o link|grep -i $MACADDR|awk '{print $2}'|sed s/://` #the nics have not been configured when running the PBS sometimes, need to make sure... RETRY=0 +NETUP=0 while true; do - #scan the nics with the specified mac address - #there will be multiple nic names for a mac address when the network bridge exists - for nic in $INSTALLNIC ;do - #check whether the nic is configured and linkup - ip -4 --oneline addr show dev $nic |grep inet >/dev/null && exit 0 - done + #scan the nics with the specified mac address + #there will be multiple nic names for a mac address when the network bridge exists + for nic in $INSTALLNIC ;do + #check whether the nic is configured and linkup + ip -4 --oneline addr show dev $nic |grep inet >/dev/null && NETUP=1 && break + done + + #nic is configured,terminate scan... + [ $NETUP -ne 0 ] && break; - RETRY=$[ $RETRY + 1 ] + RETRY=$[ $RETRY + 1 ] - if [ $RETRY -eq 90 ];then - #timeout, complain and exit - msgutil_r "$MASTER_IP" "err" `date`" xcatinstallpost: Network not configured, please check..." "/var/log/xcat/xcat.log" - exit 1 - fi - - #sleep sometime before the next scan - sleep 2 + if [ $RETRY -eq 90 ];then + #timeout, complain and exit + msgutil_r "$MASTER_IP" "err" `date`" xcatinstallpost: Network not configured, please check..." "/var/log/xcat/xcat.log" + exit 1 + fi + + #sleep sometime before the next scan + sleep 2 done