From: Aaron Klingaman <alk@cs.princeton.edu>
Date: Wed, 4 May 2005 18:09:08 +0000 (+0000)
Subject: up contact attempts to 3 and print a message indicating which server
X-Git-Tag: BOOTCD_V_3_0_FINAL~6
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=89d3fb534a325071c4274d110e40edfdb8667305;p=bootcd.git

up contact attempts to 3 and print a message indicating which server
(primary/backup) we are attempting to connect to.
---

diff --git a/conf_files/pl_boot b/conf_files/pl_boot
index a9e889a..1f5fa5a 100644
--- a/conf_files/pl_boot
+++ b/conf_files/pl_boot
@@ -11,7 +11,7 @@ CANCEL_BOOT_FLAG=/tmp/CANCEL_BOOT
 # how many times to fail in attempting to contact primary server
 # before falling back to original. if the backup fails this many times
 # too, then the process is repeated started with the primary server
-ATTEMPTS_BEFORE_BACKUP=2
+ATTEMPTS_BEFORE_BACKUP=3
 
 # where all the configuration files for contacting
 # the boot server are stored
@@ -73,14 +73,8 @@ while : ; do
 	echo "pl_boot: got request to cancel boot, exiting"
 	exit 0
     fi
-
-    if [[ $contact_count -ne 0 ]]; then
-	echo "pl_boot: fetching new script in 30 seconds"
-	/bin/sleep 30
-    fi
     
-    ((contact_count++))
-    if [[ $contact_count > $ATTEMPTS_BEFORE_BACKUP ]]; then
+    if [[ $contact_count -ge $ATTEMPTS_BEFORE_BACKUP ]]; then
 
 	contact_count=0
 
@@ -107,6 +101,16 @@ while : ; do
 	fi
     fi
 
+    if [[ $contact_count != 0 ]]; then
+
+	if [[ $on_backup_server == 1 ]]; then
+	    echo "pl_boot: attempting to fetch script from backup server in 30s"
+	else
+	    echo "pl_boot: attempting to fetch script from primary server in 30s"
+	fi
+	/bin/sleep 30
+    fi
+
     # assemble the curl transaction
     CURL_CMD="/usr/bin/curl \
         --connect-timeout 60 \
@@ -140,6 +144,7 @@ while : ; do
 	/bin/sed 's/ //g' > /tmp/nonce
 
     echo "pl_boot: fetching script from boot server $CONNECT_BOOT_SERVER"
+    ((contact_count++))
     rm -f $UNVERIFIED_SCRIPT
     $CURL_CMD
     curl_err=$?