From: Ian Kelling Date: Wed, 23 Nov 2016 02:28:17 +0000 (-0800) Subject: various fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;ds=sidebyside;h=708c79e5611549280b988c607e1a1a19fc63e991;p=automated-distro-installer various fixes --- diff --git a/fai-redep b/fai-redep index ca8fb60..c342d4b 100755 --- a/fai-redep +++ b/fai-redep @@ -65,3 +65,5 @@ chmod -R a+rX /srv/fai/config/distro-install-common #u=http://fai-project.org/download/basefiles/XENIAL64.tar.xz #wget -nv -N $u EOF + +faiserver-enable diff --git a/fai/config/class/50-host-classes b/fai/config/class/50-host-classes index f8e46de..12349be 100755 --- a/fai/config/class/50-host-classes +++ b/fai/config/class/50-host-classes @@ -51,8 +51,11 @@ # esac # fi # -if [[ -e /a/bin/fai/fai-wrapper ]] && isdebian-stable; then - echo "STABLE" +if [[ -e /a/bin/fai/fai-wrapper ]]; then + source /a/bin/distro-functions/src/identify-distros + if isdebian-stable; then + echo "STABLE" + fi fi # use a list of classes for our demo machine diff --git a/fai/config/distro-install-common/libreboot_grub.cfg b/fai/config/distro-install-common/libreboot_grub.cfg index 32ab392..69e1c52 100644 --- a/fai/config/distro-install-common/libreboot_grub.cfg +++ b/fai/config/distro-install-common/libreboot_grub.cfg @@ -13,7 +13,15 @@ function save_chosen { save_vars did_fai_check last_boot } -# we don't set this to fai check so we can't get into +# fai_check is so we can act like a pxe boot, but just for fai, and by +# using /debian_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 it also sets did_fai_check to +# a 3rd state os_true which means we did the fai check, and we don't +# want to do it again. This is useful for systems without libreboot. + +# 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=/debianstable_bootstrap # could use 0 here. @@ -23,7 +31,7 @@ for part in (ahci*4) (ata*4); do envfile=$part/grubenv if [ -s $envfile ]; then load_env --file $envfile - if [ x$did_fai_check != xtrue -a x$last_boot != x$default ]; then + if [ x$did_fai_check == xfalse -a x$last_boot != x$default ]; then set default=fai-check elif [ ! -z $last_boot ]; then set default=$last_boot diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP index 15c865f..e448c7f 100755 --- a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP +++ b/fai/config/files/root/fai-check/STABLE_BOOTSTRAP @@ -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 diff --git a/faiserver-setup b/faiserver-setup index 96485a5..a48a00c 100755 --- a/faiserver-setup +++ b/faiserver-setup @@ -52,6 +52,22 @@ fi # for debian: + +apt-get update +# all the dependencies except the dhcp server +deps="$(apt-cache show fai-quickstart | grep ^Depends: |head -n 1|\ + sed -r 's/^Depends:|,|\|[^,]+|isc-dhcp-server//g')" +to_install=(tar) +for pkg in $deps; do + dpkg -s $pkg &>/dev/null && continue ||: + to_install+=($pkg) + # just so we have a record. + echo `date` $pkg >>/var/log/fai-manually-installed-packages.log +done +if [[ $to_install ]]; then + apt-get -y install ${to_install[@]} +fi + r=http://http.us.debian.org/debian # like default, but scrap httpredir, and nonfree. # All my systems should be able to get along without nonfree @@ -78,21 +94,6 @@ Pin-Priority: 500 EOF fi -apt-get update -# all the dependencies except the dhcp server -deps="$(apt-cache show fai-quickstart | grep ^Depends: |head -n 1|\ - sed -r 's/^Depends:|,|\|[^,]+|isc-dhcp-server//g')" -to_install=(tar) -for pkg in $deps; do - dpkg -s $pkg &>/dev/null && continue ||: - to_install+=($pkg) - # just so we have a record. - echo `date` $pkg >>/var/log/fai-manually-installed-packages.log -done -if [[ $to_install ]]; then - apt-get -y install ${to_install[@]} -fi - # tried out a stretch base, doesn't work yet. $sed -f - /etc/fai/nfsroot.conf <