X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FVOL_STABLE_BOOTSTRAP;fp=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FSTABLE_BOOTSTRAP;h=7621bdf1a1a2581071ca63a2170fda7a0c1d2dca;hb=83828fe2683227f4d8ecb2343eff28439741b490;hp=c06702901fd46a1f097da9d51ad569e7e1aae492;hpb=2f13039525488532756a089b8329ab6ee64a6c17;p=automated-distro-installer diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP similarity index 50% rename from fai/config/files/root/fai-check/STABLE_BOOTSTRAP rename to fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP index c067029..7621bdf 100755 --- a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP @@ -3,6 +3,23 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + + +usage() { + cat < deadline )); then - echo "fai-check: hit $NETWORK_TIMOUT_SECS s tftp server timeout" - return 0 - fi - sleep 1 - done - m pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: - else - return 0 - fi +try-kexec() { + deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS )) + 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 + m pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||: } +case $1 in + -f|--force) + try-kexec + exit + ;; +esac + first=true for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ |sort); do @@ -46,7 +59,18 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ set +x fi first=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 + 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/ + try-kexec + else + return 0 + fi else # we make sure there is only 1 grubenv, # so grub can just find the first one, in whatever order