]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
force reboot+retry if the system doesnt come up correctly
authorHolger Levsen <holger@layer-acht.org>
Wed, 6 Mar 2013 08:40:34 +0000 (09:40 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 6 Mar 2013 08:40:34 +0000 (09:40 +0100)
pxe_install.sh

index b7cf0f1811aede6c839f0b36f41104635b791b8f..17ce4b2fe9f356d7d693483176fff1f46d63b26b 100755 (executable)
@@ -26,6 +26,7 @@ $(dirname $0)/pxe_riserver_setup.sh $TARGET_HOST $TARGET_MAC $TARGET_DEV localbo
 #ipmitool -H ${TARGET_HOST}-ipmi -f /etc/jenkins/$TARGET_HOST.ipmi -U ADMIN -I lanplus sol activate < /dev/zero | tee $TMPOUTPUT &
 
 set +x
+never_pinged=true
 #
 # check for 15min whether ssh comes back
 #
@@ -33,6 +34,7 @@ echo "Checking for sshd running on $TARGET_HOST..."
 for i in $(seq 1 90) ; do
        sleep 2
        if $(ping -c 1 $TARGET_HOST >/dev/null)  ; then
+               never_pinged=false
                sleep 8 # if it doesnt ping the timeout is 10secs anyway...
                echo -n "ping $TARGET_HOST ok..."
                # check ssh 
@@ -44,6 +46,17 @@ for i in $(seq 1 90) ; do
                fi
        else
                echo "$TARGET_HOST does not ping at $(date +%H:%M:%S)"
+               #
+               # sometimes a host doesnt boot correctly...
+               #
+               if $never_pinged && [ $i -gt -5 ] ; then
+                       figlet problem
+                       echo "Host doesn't come up, probably booted with the wrong ethernet device as $TARGET_DEV"
+                       echo "Rebooting and retrying..."
+                       echo
+                       $0 $@ &
+                       exit 0
+               fi
        fi
 done
 if ! $(nc -z $TARGET_HOST 22 ) ; then