exit 1
fi
+# ignore this line. hack to make shellcheck ignore $target
+if [[ ! $target ]]; then target=; fi
+
if ! type -t fcopy &>/dev/null; then
sudo apt-get -y install fai-client
fi
-if [[ -e /a/bin/fai/fai-wrapper ]]; then
- chroot() {
- shift
- "$@"
- }
-fi
-
-if [[ $FAI_ROOT == / ]]; then
- source /a/bin/bash_unpublished/source-state
- bprogs_dir=/a/opt/btrfs-progs-release
-else
- bprogs_dir=/srv/btrfs-progs-release
- chroot="chroot $FAI_ROOT"
-fi
-
# -r = recursive
# -i = ignore non-matching class warnings, always exit 0
# -B = no backup files
mount -o bind $src $dst
fi
+
+
$FAI/distro-install-common/end
# I run this as a single post-fai script to update things that have changed.
tmpfile1=$(mktemp)
# this can fail if we need an apt update
-$chroot /usr/bin/apt-cache policy >$tmpfile1 ||:
+$ROOTCMD /usr/bin/apt-cache policy >$tmpfile1 ||:
fcopy -riB /etc/apt
tmpfile2=$(mktemp)
-$chroot /usr/bin/apt-cache policy >$tmpfile2
+$ROOTCMD /usr/bin/apt-cache policy >$tmpfile2
if ! diff -q $tmpfile1 $tmpfile2; then
- $chroot /usr/bin/apt update
+ $ROOTCMD /usr/bin/apt update
fi
# outside of fai, this seems to regularly lead to
# E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
#### misc configurations
-
if [[ $FAI_ACTION != dirinstall ]] && ! ifclass NOCRYPT; then
if ifclass LINODE; then
speed=19200
WantedBy=dev-disk-by\x2did-ata\x2dSamsung_SSD_870_QVO_8TB_S5VUNG0N900656V.device
EOF
- $chroot bash <<'EOFOUTER'
+ $ROOTCMD bash <<'EOFOUTER'
systemctl enable myncq.service
/usr/bin/myncq no-upgrub
EOFOUTER
fi
# use networkmanager if this host has wireless.
-if [[ $HOSTNAME == bo ]] || type -p iw &>/dev/null && [[ $(iw dev) ]]; then
- $chroot bash <<EOF
+if [[ $(iw dev) || $HOSTNAME == so ]]; then
+ $ROOTCMD bash -xe <<EOF
apt-get -y install network-manager
EOF
# allow networkmanager to manage interfaces
#https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1638842
- touch $target/etc/NetworkManager/conf.d/10-globally-managed-devices.conf
+ # touch $target/etc/NetworkManager/conf.d/10-globally-managed-devices.conf
+ #
+ # in 24.04, netplan takes over and nm won't automatically connect any
+ # ethernet devices. Ya, man NetworkManager helpfully suggests the
+ # config setting device*.managed=1, but of course that isn't REAL
+ # setting, you go to man NetworkManager.conf and find that every
+ # setting has a section. So what section is that setting in? It
+ # doesn't tell you. You have to figure out that it is implied that a
+ # setting x.y means section x, setting y. Ok, but what section is
+ # device*? that isn't documented in the man page either (at least not
+ # properly). But if you read closely, you can intuit that device* is
+ # likely a valid section and then try it. Might as use this same magic
+ # config file name since it is supposed to exist, but I have no idea
+ # if it is still magic. note: In figuring this out, I also removed
+ # /etc/netplan/*, which seemed to have no effect. dunno if it matters.
+ cat >$target/etc/NetworkManager/conf.d/10-globally-managed-devices.conf <<'EOF'
+[device*]
+managed=1
+EOF
# in a default desktop install, it looks like netplan creates this file under
# run/NetworkManager/conf.d in early boot.
[main]
dns=systemd-resolved
EOF
+
+
+ if [[ ! $FAI_WRAPPER || $SSH_CLIENT ]]; then
+ # for running from fai or remote connections, don't kill the internet
+ ethusb_arg=-c
+ fi
+ if [[ $(timeout 1 dig +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]] \
+ && ip n show 10.2.0.1 | grep . &>/dev/null; then
+ # we are at_home
+ $FAI/distro-install-common/ethusb-static $ethusb_arg
+ else
+ $FAI/distro-install-common/ethusb-static off $ethusb_arg
+ fi
+
+
else
cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
fi
-# for new btrfs features, get latest stable kernel and btrfs progs,
-# update ver= as needed.
-case $HOSTNAME in
- sy)
- mkdir -p $FAI_ROOT/tmp/kernel-debs
- files=($FAI_ROOT/tmp/kernel-debs/*)
- if (( ${#files[@]} >= 1 )); then
- rm -rf "${files[@]}"
- fi
- cd $FAI_ROOT/tmp/kernel-debs
- ver='6\.6'
- va=$(curl -s https://kernel.ubuntu.com/mainline/ | \
- sed -rn 's,.*alt="\[DIR\]".*href="([^/]+).*,\1,p' | \
- grep -v -- -rc | sed 's/^v//' | grep "^$ver" | sort -V | tail -n1)
-
- # note the wiki page about these says to install linux-headers.*generic.*amd64, but
- # as of 2024, they have a requirement of a very new glibc, and people report
- # that installing it is not needed.
- pkgs=$(curl -s https://kernel.ubuntu.com/mainline/v$va/amd64/CHECKSUMS | awk '$2 ~ /^linux-/ { print $2 }' | sort -u | grep -iv 'linux-headers.*generic.*amd64' )
-
- urls=()
- for p in $pkgs; do
- if ! dpkg -s -- "${p%%_*}" 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then
- urls+=(https://kernel.ubuntu.com/mainline/v$va/amd64/$p)
- fi
- done
- if (( ${#urls[@]} >= 1 )); then
- wget "${urls[@]}"
- $chroot bash <<EOF
-cd /tmp/kernel-debs
-dpkg -i *.deb
-EOF
- fi
- ;;
- *)
- $chroot apt-get -y install linux-libre
- ;;
-esac
-
-pre=https://mirrors.edge.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs
-tarball=$(curl -s $pre/sha256sums.asc \
- | awk '$2 ~ /^btrfs-progs-v/ { print $2 }' | grep -v -- -rc | grep "^btrfs-progs-v${ver}.*gz\$" | sort -V | tail -n1)
-url="$pre/$tarball"
-dir=${tarball%.tar.gz}
-ver=${dir#btrfs-progs}
-cur_ver=$(btrfs --version 2>/dev/null | awk '{print $2}') ||:
-if [[ $ver != "$cur_ver" ]]; then
- if [[ $HOST2 == $HOSTNAME && $ver != "$($bprogs_dir/btrfs --version 2>/dev/null | awk '{print $2}')" ]]; then
- rm -rf $bprogs_dir
- cd /tmp
- wget $url
- sudo -u iank tar xzf $tarball
- mv ${tarball%.tar.gz} $bprogs_dir
- cd $bprogs_dir
- apt-get -y build-dep btrfs-progs
- sudo -u iank ./configure --disable-documentation
- sudo -u iank make
- make install
- else
- $chroot bash -xe <<EOF
-cd $bprogs_dir
-make install
-EOF
- fi
-fi
-
if ifclass LINODE; then
mkdir -p $target/etc/initramfs-tools/conf.d
+ # shellcheck disable=SC2154 # comes with LINODE environment
cat >$target/etc/initramfs-tools/conf.d/mine <<EOF
# dhcp in initramfs doesn't work on linode. i dunno why, whatever.
# man 5 initramfs.conf
##### end network setup #####
-if ifclass VOL_BULLSEYE_BOOTSTRAP; then
+if ifclass VOL_BULLSEYE_BOOTSTRAP || ifclass VOL_BOOKWORM_BOOTSTRAP; then
fcopy /etc/systemd/system/faicheck.service
- $chroot bash <<'EOFOUTER'
+ $ROOTCMD bash <<'EOFOUTER'
systemctl enable faicheck.service
EOFOUTER
exit 0 # avoid unnecessary stuff in bootstrap vol
## misc settings
-$chroot bash <<'EOFOUTER'
+$ROOTCMD bash <<'EOFOUTER'
#### begin .ssh setup ###
set -x
set -eE -o pipefail
for g in plugdev audio video cdrom; do
$ROOTCMD usermod -a -G $g user2
done
+
+
+# on server, we don't use btrfs, don't need a new kernel afaik.
+if [[ $HOSTNAME == li ]]; then
+ exit 0
+fi
+
+## begin get new kernel and btrfs-progs ##
+case $HOSTNAME in
+ sy|so)
+ # note, on sy t11, severe wifi degredation on mainline 6.8
+ $ROOTCMD apt-get -y install linux-image-generic
+ ;;
+ *)
+ if ! $ROOTCMD dpkg -s -- freesh-archive-keyring 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then
+ apt-get -y install wget
+ wget -O $target/tmp/x.deb https://linux-libre.fsfla.org/pub/linux-libre/freesh/pool/main/f/freesh-archive-keyring/freesh-archive-keyring_1.1_all.deb
+ $ROOTCMD dpkg -i /tmp/x.deb
+ $ROOTCMD apt-get update
+ $ROOTCMD apt-get -y install linux-libre
+ fi
+ ;;
+esac
+
+
+#### begin btrfs-progs
+
+# we want these files from the package:
+# /usr/share/initramfs-tools/hooks/btrfs
+# /usr/share/initramfs-tools/scripts/local-premount/btrfs
+# everything else, seems better to take from upstream package.
+for f in $(dpkg-query -L btrfs-progs | gr '/man/|^/s?bin/|^/usr/lib/udev') ; do
+ if [[ ! -f $f ]]; then
+ continue
+ fi
+ # use --no-rename so that I don't need to track whether this was the first
+ # btrfs-progs install.
+ $ROOTCMD dpkg-divert --no-rename --local --add $f
+done
+
+## using dev version for bug fix temporarily. when done, set this to false,
+## and we can stop copying it in fai-redep.
+static_ver=true
+if $static_ver; then
+ # The version with the bug fix is really some git version, but this is
+ # what it outputs for --version.
+ ver=6.10
+ bp_dirname=btrfs-progs
+ if grep -F 'VERSION_CODENAME="aramo"' /etc/os-release; then
+ bp_dirname=btrfs-progs-t11
+ fi
+else
+ bp_dirname=btrfs-progs-release
+ # latest released version.
+ pre=https://mirrors.edge.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs
+ tarball=$(curl -s $pre/sha256sums.asc \
+ | awk '$2 ~ /^btrfs-progs-v/ { print $2 }' | grep -v -- -rc | grep "^btrfs-progs-v.*gz\$" | sort -V | tail -n1)
+ url="$pre/$tarball"
+ dir=${tarball%.tar.gz}
+ ver=${dir#btrfs-progs-}
+fi
+cur_ver=$($ROOTCMD btrfs --version 2>/dev/null | head -n1 | awk '{print $2}') ||:
+
+if [[ $FAI_ROOT == / ]]; then
+ bp_dir=/a/opt/$bp_dirname
+else
+ bp_dir=$FAI/distro-install-common/$bp_dirname
+fi
+
+last_built_ver=$($bp_dir/btrfs --version 2>/dev/null | head -n1 | awk '{print $2}')
+
+if [[ $ver != "$cur_ver" ]]; then
+ # Assume we've build the static_ver version.
+ if $static_ver || [[ $ver == "$last_built_ver" ]]; then
+ if ! $ROOTCMD dpkg -s -- build-essential 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then
+ $ROOTCMD apt-get -y install build-essential
+ fi
+
+ if [[ $FAI_ROOT == / ]]; then
+ cd $bp_dir
+ make install
+ mv /usr/bin/{fsck,mkfs}.btfs /usr/sbin/
+ else
+ mkdir -p $target/tmp/bprogs
+ mount -o bind $bp_dir $target/tmp/bprogs
+ # pre-build. in t11:
+ # ./autogen.sh && ./configure --disable-documentation --prefix=/usr && make
+ # in t12, we have the docs prerequisites, so enabled documentation.
+ # We won't have the latest docs in t11, i could install them from the t12
+ # build dir, but meh.
+ $ROOTCMD bash -xe <<EOF
+cd /tmp/bprogs
+make install
+mv /usr/bin/{fsck,mkfs}.btfs /usr/sbin/
+EOF
+ fi
+ else
+ cd $target/tmp
+ wget $url
+ tar xzf $tarball
+ # if we are in a full install, gotta prevent build-dep from
+ # using repos that are pinned negative, and pulling in uninstallable
+ # packages.
+ #
+ # todo: this isn't considering the chroot.
+ if [[ -e /b/distro-functions/src/package-manager-abstractions ]]; then
+ . /b/distro-functions/src/package-manager-abstractions
+ p build-dep btrfs-progs/$(debian-codename) -y
+ else
+ $ROOTCMD apt-get -y build-dep btrfs-progs
+ fi
+ # note: docs requirements are installed when we have a full distro, so
+ # at some point, fix the build for early distro.
+ $ROOTCMD bash -xe <<EOF
+cd /tmp/${tarball%.tar.gz}
+./configure --prefix=/usr
+make
+make install
+mv /usr/bin/{fsck,mkfs}.btfs /usr/sbin/
+EOF
+ # If our desktop is HOST2, will we btrbk this latest bprogs to other
+ # machines.
+ if [[ -s /a/bin/bash_unpublished/source-state ]]; then
+ source /a/bin/bash_unpublished/source-state
+ fi
+ if [[ $HOST2 == "$HOSTNAME" && $FAI_ROOT != / ]]; then
+ rm -rf $bp_dir
+ chown -R iank:iank $target/tmp/${tarball%.tar.gz}
+ mv $target/tmp/${tarball%.tar.gz} $bp_dir
+ fi
+
+
+ fi
+fi
+## end get new kernel and btrfs-progs ##