X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Fscripts%2FIANK%2F11-iank;h=54641b237bcc10b15b30b90bb0f8b662253f8609;hb=HEAD;hp=0b8d6c5576caba9763234f1de2bbca79f9a0e41a;hpb=f856a11aa6b4aaa454a5c93c4f1d9672591ca2eb;p=automated-distro-installer diff --git a/fai/config/scripts/IANK/11-iank b/fai/config/scripts/IANK/11-iank index 0b8d6c5..99316b8 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,22 +24,13 @@ 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 - -if [[ $FAI_ROOT != / ]]; then - bprogs_pre=/srv - chroot="chroot $FAI_ROOT" -fi - # -r = recursive # -i = ignore non-matching class warnings, always exit 0 # -B = no backup files @@ -47,6 +54,8 @@ if [[ ! -e $dst && -e $src ]]; then mount -o bind $src $dst fi + + $FAI/distro-install-common/end @@ -56,13 +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 /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) @@ -86,7 +95,6 @@ fi #### misc configurations - if [[ $FAI_ACTION != dirinstall ]] && ! ifclass NOCRYPT; then if ifclass LINODE; then speed=19200 @@ -112,12 +120,12 @@ TimeoutStartSec=20 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 - ;; + ;;& # per rubens suggestion to make a d16 more stable kd|kw) cmdline+=" pci=realloc=off" ;; esac @@ -161,8 +169,8 @@ EOF fi # use networkmanager if this host has wireless. -if [[ $HOSTNAME == bo ]] || type -p iw &>/dev/null && [[ $(iw dev) ]]; then - $chroot bash <&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 @@ -205,42 +228,9 @@ EOF fi -# for btrfs bug reporting, install latest kernel and btrfs progs, as of -# 2023-07-21 -case $HOSTNAME in - sy) - mkdir -p $FAI_ROOT/tmp/kernel-debs - cd $FAI_ROOT/tmp/kernel-debs - va=6.4.3 - vb=$va-060403 - vc=${vb}.202307110536 - pre="https://kernel.ubuntu.com/~kernel-ppa/mainline/v$va/amd64/linux-" - if ! dpkg -s -- linux-headers-${vb} 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then - urls=( - ${pre}headers-${vb}_${vc}_all.deb - ${pre}{headers,image-unsigned,modules}-${vb}-generic_${vc}_amd64.deb - ) - wget "${urls[@]}" - $chroot bash <$target/etc/initramfs-tools/conf.d/mine <&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 + +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-} +cur_ver=$($ROOTCMD btrfs --version 2>/dev/null | awk '{print $2}') ||: + +if [[ $FAI_ROOT == / ]]; then + bp_dir=/a/opt/btrfs-progs-release +else + bp_dir=$FAI/distro-install-common/btrfs-progs-release +fi +if [[ $ver != "$cur_ver" ]]; then + if [[ $ver != "$($bp_dir/btrfs --version 2>/dev/null | awk '{print $2}')" ]]; then + cd $target/tmp + wget $url + tar xzf $tarball + $ROOTCMD apt-get -y build-dep btrfs-progs + # no docs cuz I didn't want to bother fixing error of missing docs dependencies + $ROOTCMD bash -xe <&1 | grep -Fx "Status: install ok installed" &>/dev/null; then + $ROOTCMD apt-get -y install build-essential + fi + + if [[ $FAI_ROOT == / ]]; then + cd /a/opt/btrfs-progs-release + make install + else + mkdir -p $target/tmp/bprogs + mount -o bind $bp_dir $target/tmp/bprogs + $ROOTCMD bash -xe <