X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FSTABLE_BOOTSTRAP;h=e448c7f7b1bd7429d0ad27e24304d07b40acb272;hb=708c79e5611549280b988c607e1a1a19fc63e991;hp=29bb1fbb7272813e1755b349000bef79bd7c3cd4;hpb=d6df8985152a6c17523cedc3fee62694544eeaf2;p=automated-distro-installer diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP index 29bb1fb..e448c7f 100755 --- a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP @@ -3,12 +3,20 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR -fai_check=false +# keep it short so we don't delay too much wnen we don't have networking. +NETWORK_TIMOUT_SECS=10 +did_fai_check=false check-fai() { # we could just as well check if last_boot != /debianstable_boostrap # the intent with this one is just a little clearer. if [[ $did_fai_check == true ]]; then - fai_check=true + grub-editenv /mnt/grubenv set did_fai_check=os_true + # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ + deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS )) + while ! systemctl status network-online.target && \ + (( `date +%s` < deadline )); do + sleep 1 + done pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: else return 0 @@ -37,7 +45,8 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ umount /mnt done -if $fai_check && [[ $last_boot != /debianstable_boostrap ]]; then +# the check for last_boot is not needed afaik, just sanity check. +if [[ $did_fai_check == true && $last_boot != /debianstable_boostrap ]]; then # no need to reboot if we actually want to boot into this os. reboot fi