various fixes
[automated-distro-installer] / fai / config / files / root / fai-check / STABLE_BOOTSTRAP
index 15c865f671f1007cf05a5361a0524375103946b5..e448c7f7b1bd7429d0ad27e24304d07b40acb272 100755 (executable)
@@ -5,12 +5,12 @@ 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
-fai_check=false
+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 && \
@@ -45,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