X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;ds=inline;f=fai%2Fconfig%2Fscripts%2FIANK%2F11-iank;h=54641b237bcc10b15b30b90bb0f8b662253f8609;hb=HEAD;hp=47b97ad98720d08c4d48338369b413929180bbf5;hpb=051fc89e27bd812a1a45292f6d2a18803ce6f394;p=automated-distro-installer diff --git a/fai/config/scripts/IANK/11-iank b/fai/config/scripts/IANK/11-iank index 47b97ad..a10a5bb 100755 --- a/fai/config/scripts/IANK/11-iank +++ b/fai/config/scripts/IANK/11-iank @@ -1,4 +1,20 @@ #!/bin/bash -x +# This file is part of Ian Kelling's automated-distro-installer +# Copyright (C) 2024 Ian Kelling + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -8,31 +24,26 @@ if [[ $EUID != 0 ]]; then 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 - - - # -r = recursive # -i = ignore non-matching class warnings, always exit 0 # -B = no backup files -fcopy -riBM /boot +fcopy -riB /boot # this is also done by FAIBASE/10-misc by default (without B) -fcopy -riBM /root -fcopy -riBM /usr/local/bin +fcopy -riB /usr/local/bin + +fcopy -riB /etc/apt/logind.conf.d # this gets done by fai, but just happens too often that # I add sources due to new distros, whatever. -fcopy -riBM /etc/apt/preferences.d -fcopy -riBM /etc/apt/sources.list.d +fcopy -riB /etc/apt/preferences.d +fcopy -riB /etc/apt/sources.list.d src=$FAI/distro-install-common/shadow @@ -43,6 +54,8 @@ if [[ ! -e $dst && -e $src ]]; then mount -o bind $src $dst fi + + $FAI/distro-install-common/end @@ -52,16 +65,13 @@ $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 $FAI_ROOT /usr/bin/apt-cache policy >$tmpfile1 ||: -fcopy -riBM /etc/apt - -# get ubuntu key, for running from fai wrapper. -apt-key add $FAI/package_config/UBUNTU.asc +$ROOTCMD /usr/bin/apt-cache policy >$tmpfile1 ||: +fcopy -riB /etc/apt tmpfile2=$(mktemp) -chroot $FAI_ROOT /usr/bin/apt-cache policy >$tmpfile2 +$ROOTCMD /usr/bin/apt-cache policy >$tmpfile2 if ! diff -q $tmpfile1 $tmpfile2; then - chroot $FAI_ROOT /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) @@ -84,29 +94,8 @@ fi #### misc configurations -chroot $FAI_ROOT bash <<'EOFOUTER' -if getent group systemd-journal >/dev/null; then - # makes the journal be saved to disk. - mkdir -p /var/log/journal - chmod 755 /var/log/journal -fi -debconf-set-selections <$FAI_ROOT/etc/grub.d/40_custom </dev/null; then - update-grub2 -else - update-grub -fi - -EOF fi ##### end != dirinstall && != NOCRYPT @@ -213,7 +156,9 @@ esac # xorg stopped load nouveau # https://www.linuxquestions.org/questions/slackware-14/kernel-modules-conflicting-with-nouveau-driver-4175623867/ # https://nouveau.freedesktop.org/InstallNouveau.html -if lspci|grep -q 'GeForce GTX 6[0-9][0-9]\]'; then +# And now in t11, things got worse with a newer card also not loading +# nouveau when it did in t10. +if lspci|grep -q 'VGA compatible controller: NVIDIA'; then mkdir -p $target/etc/X11/xorg.conf.d/ cat >$target/etc/X11/xorg.conf.d/10-nouveau.conf <<'EOF' Section "Device" @@ -224,14 +169,32 @@ EOF fi # use networkmanager if this host has wireless. -if [[ $HOSTNAME == bo ]] || type -p iw &>/dev/null && [[ $(iw dev) ]]; then - chroot $FAI_ROOT bash <$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. @@ -242,18 +205,21 @@ EOF [main] dns=systemd-resolved EOF - if [[ $HOSTNAME == frodo ]]; then - cat > $target/etc/network/interfaces <<-EOF -# generated by FAI -auto lo eth0 -iface lo inet loopback -iface eth0 inet static -address 10.3.0.2/16 -source-directory /etc/network/interfaces.d -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 @@ -282,6 +248,7 @@ 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 < $target/etc/network/interfaces <<-EOF # generated by FAI auto lo eth0 @@ -315,19 +281,13 @@ EOF fi fi -# I prefer to stick with ifup/down for now. a. networkd is not in its -# own package, so cant use in other init systems. b. it works fine. -chroot $FAI_ROOT bash <&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 <