From: Ian Kelling Date: Thu, 5 Feb 2026 22:59:54 +0000 (-0500) Subject: fixes mostly for newer fai X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=f484b85bd308bf296f68e442f0a568692f73425b;p=automated-distro-installer fixes mostly for newer fai --- diff --git a/fai-wrapper b/fai-wrapper index b6a75d3..962c48c 100644 --- a/fai-wrapper +++ b/fai-wrapper @@ -23,10 +23,13 @@ # This wrapper can be detected by using this var: export FAI_WRAPPER=true -ifclass() { - local var=${1/#/CLASS_} - [[ $HOSTNAME == "$1" || ${!var} ]] -} +# note: fai changed how classes get defined & checked, now its all in the "classes" env var. +# And we have a binary outside fai, so don't need this. +# ifclass() { +# local var=${1/#/CLASS_} +# [[ $HOSTNAME == "$1" || ${!var} ]] +# } +#export -f ifclass fai-setclass() { for class in "$@"; do # export class vars with CLASS_ in front to avoid name collisions. @@ -44,9 +47,9 @@ eval-fai-classfile() { fi fai-setclass $(bash $file) } -export -f ifclass # DEFAULT is used by fcopy classes="DEFAULT $(hostname)" +export classes export CLASS_DEFAULT=true if [[ ! -d $FAI_ROOT ]]; then export FAI_ROOT=/ diff --git a/fai/config/distro-install-common/end b/fai/config/distro-install-common/end index a3c4bb4..8a1b72c 100755 --- a/fai/config/distro-install-common/end +++ b/fai/config/distro-install-common/end @@ -98,7 +98,7 @@ Defaults:root,iank !log_allowed, !pam_session Defaults>root env_file=/etc/rootsudoenv # a few commands we should be able to run with no password -iank ALL = (root) NOPASSWD: /usr/local/bin/spend,/usr/local/bin/us,/usr/local/bin/off,/usr/bin/nmtui-connect,/usr/local/bin/bitcoinoff,/usr/local/bin/bitcoinon +iank ALL = (root) NOPASSWD: /usr/local/bin/spend,/usr/local/bin/us,/usr/local/bin/off,/usr/bin/nmtui-connect,/usr/local/bin/bitcoinoff,/usr/local/bin/bitcoinon,/usr/local/bin/i3-misc1 EOF diff --git a/fai/config/distro-install-common/new-btrfs-progs b/fai/config/distro-install-common/new-btrfs-progs index 086c25d..3116383 100644 --- a/fai/config/distro-install-common/new-btrfs-progs +++ b/fai/config/distro-install-common/new-btrfs-progs @@ -27,8 +27,20 @@ if ! type -p wget &>/dev/null; then fi + $ROOTCMD apt-get -y install btrfs-progs -for f in $(dpkg-query -L btrfs-progs | grep -E '/man/|^/s?bin/|^/usr/lib/udev') ; do +# Running dpkg-divert on the same file twice will cause an error. +# Those files are identified in the output of dpkg-query -L like so: +# /usr/share/man/man8/mkfs.btrfs.8.gz +# locally diverted to: /usr/share/man/man8/mkfs.btrfs.8.gz.distrib +# So, with sed we look forward to the next line before printing and +# if the next line says locally diverted, we avoid printing. If the previous +# line is "locally diverted", also avoid printing it. On the last +# line, we don't wait to look forward, just print as long as it is +# not a "locally diverted" line. +for f in $(dpkg-query -L btrfs-progs | \ + sed -r '/^locally diverted/{x;d};$p;x;/^locally diverted/d' | \ + grep -E '/man/|^/s?bin/|^/usr/lib/udev') ; do if [[ ! -f $f ]]; then continue fi @@ -108,7 +120,7 @@ EOF # todo: this isn't considering the chroot, assumes we've built it # outside the chroot and won't get into this case. if [[ -e /b/distro-functions/src/identify-distros ]]; then - . /b/distro-functions/src/identify-distros + for f in /b/distro-functions/src/*; do . $f; done debian_codename=$(debian-codename) p build-dep btrfs-progs/$debian_codename -y else diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index cc7ff9e..4e1b851 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -30,9 +30,7 @@ usage() { cat <<'EOF' Example of calling outside of FAI: -Optionally: source /b/fai/fai-wrapper (note: this exports everything, including functions) and -set any appropriate classes with: fai-setclass OPT1... which sets CLASS_OPT1=true... -or run eval-fai-classfile FILE. + /a/bin/fai/fai/config/hooks/partition.DEFAULT @@ -40,7 +38,7 @@ Example use in a bootstrap distro: scp /b/fai/fai-wrapper /a/bin/fai/fai/config/{distro-install-common/devbyid,hooks/partition.DEFAULT} root@HOST: sl root@HOST . fai-wrapper # ignore error that FAI is not set, it is not needed for SPECIAL_DISK purposes. -fai-setclass FSF +fai-setclass FSF # note, we could also do: eval-fai-classfile FILE. ./partition.DEFAULT -s /dev/sde cat /tmp/fai/crypttab >>/etc/crypttab cat /tmp/fai/fstab >>/etc/fstab @@ -118,16 +116,29 @@ EOF exit $1 } +# duplicated in fai-wrapper +fai-setclass() { + for class in "$@"; do + classes+=" $class" + # old fai way. + # export CLASS_$class=true + done + classes="${classes# }" + export classes +} +if [[ ! $classes ]]; then + classes="DEFAULT $(hostname)" + export classes +fi + -## duplicates fai-wrapper, for convenience of not needing it if ! type -t ifclass &>/dev/null; then - ifclass() { - local var=${1/#/CLASS_} - [[ $HOSTNAME == "$1" || ${!var} ]] - } + echo "$0: error: install ifclass" >&2 + exit 1 fi + ##### begin command line parsing ######## data_part=false @@ -182,7 +193,7 @@ fi if [[ $special_disk ]]; then - export CLASS_REPARTITION=true + fai-setclass REPARTITION fi # # fai's setup-storage won't do btrfs on luks,