From ebaede570d7d8ac32ff2d405fad5d6100455de41 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 6 Mar 2013 09:40:34 +0100 Subject: [PATCH] force reboot+retry if the system doesnt come up correctly --- pxe_install.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pxe_install.sh b/pxe_install.sh index b7cf0f1..17ce4b2 100755 --- a/pxe_install.sh +++ b/pxe_install.sh @@ -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 -- 2.39.5