# 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.
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=/
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
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
# 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
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
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
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
if [[ $special_disk ]]; then
- export CLASS_REPARTITION=true
+ fai-setclass REPARTITION
fi
# # fai's setup-storage won't do btrfs on luks,