X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=conf_files%2Fpl_boot;h=a9e889a70758eb060068e579024f740b1bbb61f0;hb=0e339dc881d13f516f3f177df483d3f7e25a6b9c;hp=1d5abab8fe01e17b272fc3b15c0297e7ad1ea151;hpb=96949585001ec30528617d507fa2cfa081adaac6;p=bootcd.git diff --git a/conf_files/pl_boot b/conf_files/pl_boot index 1d5abab..a9e889a 100644 --- a/conf_files/pl_boot +++ b/conf_files/pl_boot @@ -8,6 +8,11 @@ export GNUPGHOME # if this file is present, cancel the boot (exit this script) 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 + # where all the configuration files for contacting # the boot server are stored BOOT_DIR=/usr/boot/ @@ -17,13 +22,26 @@ BOOT_SERVER=`cat $BOOT_DIR/boot_server` BOOT_SERVER_PORT=`cat $BOOT_DIR/boot_server_port` # the file to request from the boot server -SERVER_BOOT_DIR=`cat $BOOT_DIR/boot_server_path` +BOOT_SERVER_PATH=`cat $BOOT_DIR/boot_server_path` # location of the cacert for this boot server -BOOT_CACERT=$BOOT_DIR/cacert.pem +BOOT_SERVER_CACERT=$BOOT_DIR/cacert.pem # location of the gpg key ring to verify scripts -BOOT_GPG_KEYRING=$BOOT_DIR/pubring.gpg +BOOT_SERVER_GPG_KEYRING=$BOOT_DIR/pubring.gpg + +# get the backup server we are going to be contacting +BACKUP_BOOT_SERVER=`cat $BOOT_DIR/backup/boot_server` +BACKUP_BOOT_SERVER_PORT=`cat $BOOT_DIR/backup/boot_server_port` + +# the file to request from the backup boot server +BACKUP_BOOT_SERVER_PATH=`cat $BOOT_DIR/backup/boot_server_path` + +# location of the cacert for the backup boot server +BACKUP_BOOT_SERVER_CACERT=$BOOT_DIR/backup/cacert.pem + +# location of the gpg key ring for backup server to verify scripts +BACKUP_BOOT_SERVER_GPG_KEYRING=$BOOT_DIR/backup/pubring.gpg # location of a file containing this boot cd version BOOT_VERSION_FILE=/pl_version @@ -32,58 +50,96 @@ BOOT_VERSION_FILE=/pl_version UNVERIFIED_SCRIPT=/tmp/bootscript.gpg VERIFIED_SCRIPT=/tmp/bootscript -# asemble the curl transaction -CURL_CMD="/usr/bin/curl \ - --connect-timeout 60 \ - --max-time 600 \ - --form version=<$BOOT_VERSION_FILE \ - --form cmdline= $ATTEMPTS_BEFORE_BACKUP ]]; then + + contact_count=0 + + if [[ $on_backup_server == 1 ]]; then + echo "pl_boot: failed to contact backup server, trying primary." + + on_backup_server=0 + + CONNECT_BOOT_SERVER=$BOOT_SERVER + CONNECT_BOOT_SERVER_PORT=$BOOT_SERVER_PORT + CONNECT_BOOT_SERVER_PATH=$BOOT_SERVER_PATH + CONNECT_BOOT_SERVER_GPG_KEYRING=$BOOT_SERVER_GPG_KEYRING + CONNECT_BOOT_SERVER_CACERT=$BOOT_SERVER_CACERT + else + echo "pl_boot: failed to contact primary server, trying backup." + + on_backup_server=1 + + CONNECT_BOOT_SERVER=$BACKUP_BOOT_SERVER + CONNECT_BOOT_SERVER_PORT=$BACKUP_BOOT_SERVER_PORT + CONNECT_BOOT_SERVER_PATH=$BACKUP_BOOT_SERVER_PATH + CONNECT_BOOT_SERVER_GPG_KEYRING=$BACKUP_BOOT_SERVER_GPG_KEYRING + CONNECT_BOOT_SERVER_CACERT=$BACKUP_BOOT_SERVER_CACERT + fi + fi + + # assemble the curl transaction + CURL_CMD="/usr/bin/curl \ + --connect-timeout 60 \ + --max-time 600 \ + --form version=<$BOOT_VERSION_FILE \ + --form cmdline= /tmp/nonce - echo "pl_boot: fetching script from boot server $BOOT_SERVER" + echo "pl_boot: fetching script from boot server $CONNECT_BOOT_SERVER" rm -f $UNVERIFIED_SCRIPT $CURL_CMD curl_err=$?