X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FVOL_BULLSEYE_BOOTSTRAP;fp=fai%2Fconfig%2Ffiles%2Froot%2Ffai-check%2FVOL_BULLSEYE_BOOTSTRAP;h=a2502387eddd999baeb483bff6fa252aee78e53e;hp=6f011945d269ef8f7f1a28169692e150e57bfc81;hb=ceeb4e46d3bb326d01fcc7ed98d94ab0b580eda3;hpb=79cd04733bf570db299ef09195c498a63f3f3fd5 diff --git a/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP index 6f01194..a250238 100755 --- a/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP @@ -3,7 +3,7 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR - +#set -x usage() { cat </dev/null; then + echo "not x200, exiting" + exit 0 +fi + first=true for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ |sort); do - + echo dev=$dev found=false # Decide which is my grub_ext partition. see partition.DEFAULT file # for details. currently it is 4 @@ -70,6 +75,7 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ if [[ $(blockdev --getsize64 ${dev}$i) == 8388608 ]]; then grub_extn=${dev}$i found=true + echo grub_extn=$grub_extn break fi done @@ -77,18 +83,17 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ echo "$0: error: failed to find grub_ext partition." exit 1 fi - mount $grub_extn /mnt + m mount $grub_extn /mnt if $first; then if [[ -e /mnt/grubenv ]]; then - set -x + m grub-editenv /mnt/grubenv list source <(grub-editenv /mnt/grubenv list) - set +x fi first=false # we could just as well check if last_boot != /debianbullseye_bootstrap # 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 + m 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. @@ -101,13 +106,17 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \ # if looks at them, which may not be the same as us. # If the disk dies, we just lose the default boot option, # we will have to do manual steps to replace it anyways. - rm -f /mnt/gruvenv + m rm -f /mnt/gruvenv fi - umount /mnt + m umount /mnt done # the check for last_boot is not needed afaik, just sanity check. -if [[ $did_fai_check == true && $last_boot != /debianbullseye_bootstrap ]]; then - # no need to reboot if we actually want to boot into this os. - reboot -fi +case $did_fai_check in + true|os_true) + if [[ $last_boot != /debianbullseye_bootstrap ]]; then + # no need to reboot if we actually want to boot into this os. + echo "last_boot not debianbullseye_bootstrap, rebooting" + reboot + fi +esac