From: Ian Kelling Date: Mon, 22 Apr 2024 16:01:10 +0000 (-0400) Subject: further bookworm support X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=936324619541130f4ab07bd4633f48eb81812613;p=automated-distro-installer further bookworm support --- diff --git a/fai-revm b/fai-revm index 8bfb970..050ecda 100755 --- a/fai-revm +++ b/fai-revm @@ -140,7 +140,7 @@ else BASEFILE_DIR=/tmp fi isopath=$BASEFILE_DIR/$iso - isosrc=$BASEFILE_DIR/BULLSEYE64.tar.gz + isosrc=$BASEFILE_DIR/BOOKWORM64.tar.gz if [[ ! -e $isopath || $(stat -c %Y $isopath) -lt $(stat -c %Y $isosrc) ]]; then e fai-cd -g $(readlink -f grub.cfg.${iso%%.*}) -f -A $isopath fi diff --git a/fai/config/class/FAIBASE.var b/fai/config/class/FAIBASE.var index dabfb06..34d95ac 100644 --- a/fai/config/class/FAIBASE.var +++ b/fai/config/class/FAIBASE.var @@ -21,4 +21,4 @@ MAXPACKAGES=800 #USERPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1' # set a default -FAI_DEBOOTSTRAP="bullseye http://deb.debian.org/debian" +FAI_DEBOOTSTRAP="bookworm http://deb.debian.org/debian" diff --git a/fai/config/distro-install-common/end b/fai/config/distro-install-common/end index 8ad84c9..f9a0840 100755 --- a/fai/config/distro-install-common/end +++ b/fai/config/distro-install-common/end @@ -32,7 +32,7 @@ au() { # add user. i don't use adduser for portability # only setup root pass for bootstrap vol -if ifclass VOL_BULLSEYE_BOOTSTRAP; then +if ifclass VOL_BULLSEYE_BOOTSTRAP || VOL_BOOKWORM_BOOTSTRAP; then exit 0 fi diff --git a/fai/config/distro-install-common/libreboot_grub.cfg b/fai/config/distro-install-common/libreboot_grub.cfg index d9dde28..5f4d722 100644 --- a/fai/config/distro-install-common/libreboot_grub.cfg +++ b/fai/config/distro-install-common/libreboot_grub.cfg @@ -14,7 +14,7 @@ function save_chosen { } # fai_check is so we can act like a pxe boot, but just for fai, and by -# using /bullseye_bootstrap to do it. We toggle on and off the grub var +# using /bookworm_bootstrap to do it. We toggle on and off the grub var # did_fai_check so we can do the check every other boot. Then # /debian_bootstrap checks for that var on boot and if we want to do a # fai check, it does it, then reboots. But fai-check also sets @@ -25,7 +25,7 @@ function save_chosen { # We don't set this to fai check so we can't get into # an infinite reboot cycle. We depend on the os to # create the initial grubenv file. -set default=/debianbullseye_bootstrap # could use 0 here. +set default=/debianbookworm_bootstrap # could use 0 here. set timeout=1 # grub_extn @@ -44,7 +44,7 @@ done did_fai_check=false -bs_dir=/debianbullseye_bootstrap +bs_dir=/debianbookworm_bootstrap menuentry $bs_dir --id=$bs_dir { # note, we might be able to use $chosen and avoid setting this here, # and set it inside save_chosen. but I haven't tested it, diff --git a/fai/config/files/etc/fai/nfsroot.conf/FAISERVER b/fai/config/files/etc/fai/nfsroot.conf/FAISERVER index 72491fd..e176a6d 100644 --- a/fai/config/files/etc/fai/nfsroot.conf/FAISERVER +++ b/fai/config/files/etc/fai/nfsroot.conf/FAISERVER @@ -1,7 +1,7 @@ # For a detailed description see nfsroot.conf(5) # " " for debootstrap -FAI_DEBOOTSTRAP="bullseye http://deb.debian.org/debian" +FAI_DEBOOTSTRAP="bookworm http://deb.debian.org/debian" FAI_ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1' NFSROOT=/srv/fai/nfsroot diff --git a/fai/config/files/etc/systemd/system/faicheck.service/VOL_BOOKWORM_BOOTSTRAP b/fai/config/files/etc/systemd/system/faicheck.service/VOL_BOOKWORM_BOOTSTRAP new file mode 120000 index 0000000..82dea76 --- /dev/null +++ b/fai/config/files/etc/systemd/system/faicheck.service/VOL_BOOKWORM_BOOTSTRAP @@ -0,0 +1 @@ +VOL_BULLSEYE_BOOTSTRAP \ No newline at end of file diff --git a/fai/config/files/root/fai-check/VOL_BOOKWORM_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_BOOKWORM_BOOTSTRAP new file mode 100755 index 0000000..ebbedbe --- /dev/null +++ b/fai/config/files/root/fai-check/VOL_BOOKWORM_BOOTSTRAP @@ -0,0 +1,128 @@ +#!/bin/bash + +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + +#set -x + +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 ||: +} + +force=false +case $1 in + -h|--help) + usage + ;; + -f|--force) + force=true + shift + ;; +esac + +faiserver=${1:-faiserver.b8.nz} + + +if $force; then + try-kexec + exit +fi + +# on one machine, I could do this: +# dmidecode -t system | grep -F "Version: ThinkPad X200" +# however, on another, the version field just says invalid data. +# todo: figure out some better way to check if we are on +# an x200. + +if ! dmidecode | grep -i thinkpad &>/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 + for (( i=4; i<=7; i++ )); do + if [[ $(blockdev --getsize64 ${dev}$i) == 8388608 ]]; then + grub_extn=${dev}$i + found=true + echo grub_extn=$grub_extn + break + fi + done + if ! $found; then + echo "$0: error: failed to find grub_ext partition." + exit 1 + fi + m mount $grub_extn /mnt + if $first; then + if [[ -e /mnt/grubenv ]]; then + m grub-editenv /mnt/grubenv list + source <(grub-editenv /mnt/grubenv list) + 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 + 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. + # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ + try-kexec ||: + fi + else + # we make sure there is only 1 grubenv, + # so grub can just find the first one, in whatever order + # 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. + m rm -f /mnt/gruvenv + fi + m umount /mnt +done + +# the check for last_boot is not needed afaik, just sanity check. +case $did_fai_check in + true|os_true) + if [[ $last_boot != /debian*_bootstrap ]]; then + # no need to reboot if we actually want to boot into this os. + echo "last_boot=$last_boot not debian*_bootstrap, rebooting" + reboot + fi +esac diff --git a/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP deleted file mode 100755 index 34f682f..0000000 --- a/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR - -#set -x - -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 ||: -} - -force=false -case $1 in - -h|--help) - usage - ;; - -f|--force) - force=true - shift - ;; -esac - -faiserver=${1:-faiserver.b8.nz} - - -if $force; then - try-kexec - exit -fi - -# on one machine, I could do this: -# dmidecode -t system | grep -F "Version: ThinkPad X200" -# however, on another, the version field just says invalid data. -# todo: figure out some better way to check if we are on -# an x200. - -if ! dmidecode | grep -i thinkpad &>/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 - for (( i=4; i<=7; i++ )); do - if [[ $(blockdev --getsize64 ${dev}$i) == 8388608 ]]; then - grub_extn=${dev}$i - found=true - echo grub_extn=$grub_extn - break - fi - done - if ! $found; then - echo "$0: error: failed to find grub_ext partition." - exit 1 - fi - m mount $grub_extn /mnt - if $first; then - if [[ -e /mnt/grubenv ]]; then - m grub-editenv /mnt/grubenv list - source <(grub-editenv /mnt/grubenv list) - 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 - 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. - # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ - try-kexec ||: - fi - else - # we make sure there is only 1 grubenv, - # so grub can just find the first one, in whatever order - # 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. - m rm -f /mnt/gruvenv - fi - m umount /mnt -done - -# the check for last_boot is not needed afaik, just sanity check. -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 diff --git a/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP new file mode 120000 index 0000000..18c54eb --- /dev/null +++ b/fai/config/files/root/fai-check/VOL_BULLSEYE_BOOTSTRAP @@ -0,0 +1 @@ +VOL_BOOKWORM_BOOTSTRAP \ No newline at end of file diff --git a/fai/config/hooks/instsoft.DEFAULT b/fai/config/hooks/instsoft.DEFAULT index 3bf0f62..42f9739 100755 --- a/fai/config/hooks/instsoft.DEFAULT +++ b/fai/config/hooks/instsoft.DEFAULT @@ -3,7 +3,7 @@ # These are things we can do before package_config packages get installed. # exit for any vm except demohost, or if we are doing a dirinstall -if ifclass VM && ! ifclass demohost || ifclass VOL_BULLSEYE_BOOTSTRAP || [[ ! $FAI_ACTION || $FAI_ACTION = dirinstall ]]; then +if ifclass VM && ! ifclass demohost || ifclass VOL_BULLSEYE_BOOTSTRAP || ifclass VOL_BOOKWORM_BOOTSTRAP || [[ ! $FAI_ACTION || $FAI_ACTION = dirinstall ]]; then exit 0 fi diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 63235f1..18f5a23 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -272,7 +272,7 @@ mktab() { dev=${boot_devs[0]} fstabstd="x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s" - if [[ $DISTRO == debianbullseye_bootstrap ]]; then + if [[ $DISTRO == *_bootstrap ]]; then cat > /tmp/fai/fstab <