X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FSTABLE_BOOTSTRAP;h=c06702901fd46a1f097da9d51ad569e7e1aae492;hp=e448c7f7b1bd7429d0ad27e24304d07b40acb272;hb=a018c3030b0ebd751d5667efd96c2fd32f2423e0;hpb=1728af7e3060c8608c622f210d6e16f7d085d8f9 diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP index e448c7f..c067029 100755 --- a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP @@ -3,21 +3,32 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR -# keep it short so we don't delay too much wnen we don't have networking. -NETWORK_TIMOUT_SECS=10 +# Keep it short so we don't delay too much wnen we don't have networking. +# In practice, on my home network, on an x200, it took 15 seconds, so +# give it an extra 10 seconds, which seems fairly short as I write this. +NETWORK_TIMOUT_SECS=25 did_fai_check=false + +m() { printf "%s\n" "$*"; "$@"; } + 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 grub-editenv /mnt/grubenv set did_fai_check=os_true + # our service does not wait for network-online.target, + # because it will wait for too long when we don't have a network + # connection. So, we wait for 10 seconds. # 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 + while ! nc -zu faiserver 69; do + if (( `date +%s` > deadline )); then + echo "fai-check: hit $NETWORK_TIMOUT_SECS s tftp server timeout" + return 0 + fi sleep 1 done - pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: + m pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: else return 0 fi @@ -30,7 +41,9 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ mount $dev /mnt if $first; then if [[ -e /mnt/grubenv ]]; then + set -x source <(grub-editenv /mnt/grubenv list) + set +x fi first=false check-fai