minor fixes, refactor, network config
authorIan Kelling <iank@fsf.org>
Tue, 11 Mar 2025 03:45:38 +0000 (23:45 -0400)
committerIan Kelling <iank@fsf.org>
Tue, 11 Mar 2025 03:45:38 +0000 (23:45 -0400)
fai/config/distro-install-common/new-btrfs-progs [new file with mode: 0644]
fai/config/scripts/DEBIAN/11-iank
fai/config/scripts/IANK/11-iank
wrt-setup-local

diff --git a/fai/config/distro-install-common/new-btrfs-progs b/fai/config/distro-install-common/new-btrfs-progs
new file mode 100644 (file)
index 0000000..f492a66
--- /dev/null
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# 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.
+
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
+
+if [[ ! -d $FAI_ROOT ]]; then
+  export FAI_ROOT=/
+fi
+
+### dependencies
+{
+  for f in $(dpkg-query -L btrfs-progs | grep '/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
+
+  # from packages listed in .github/workflows/devel.yml
+  # The dumb makefile makes us build docs even if they were already built.
+  if ! type -p sphinx-build &>/dev/null; then
+    $ROOTCMD apt-get -y install python3-sphinx-rtd-theme
+  fi
+
+  if ! type -p curl &>/dev/null; then
+    $ROOTCMD apt-get -y install curl
+  fi
+  if ! type -p wget &>/dev/null; then
+    $ROOTCMD apt-get -y install wget
+  fi
+}
+
+
+## If we need to use a dev version temporarily, this to true
+## and copy it over in fai-redep. See comment there.
+static_ver=false
+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
+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
+  if [[ ! -d $bp_dir ]]; then
+    bp_dir=/root/$bp_dirname
+  fi
+else
+  bp_dir=$FAI/distro-install-common/$bp_dirname
+fi
+
+last_built_ver=$([[ ! -e $bp_dir/btrfs ]] || $bp_dir/btrfs --version 2>/dev/null | head -n1 | awk '{print $2}')
+
+# todo: this doesn't account for multiple distros versions that require
+# their own builds.
+if [[ $ver != "$cur_ver" ]]; then
+  # Assumes we've pre-built the static_ver version if we are using that.
+  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}.btrfs /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}.btrfs /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, 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
+      debian_codename=$(debian-codename)
+      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}.btrfs /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
index 2f2c6bb8f9f83a2e9ef56ea4435b9e31aeba10b0..37915bde99f51e4fcab9f06fc0e1d3d083c9f8e7 100755 (executable)
@@ -151,7 +151,7 @@ fi
 # own package, so cant use in other init systems. b. it works fine.
 chroot $FAI_ROOT bash <<EOF
 # in debian bookworm, this service no longer exists by default
-if systemctl cat networkd-dispatcher.service &>/dev/null; then
+if [[ -e networkd-dispatcher.service ]]; then
   systemctl disable networkd-dispatcher
   systemctl mask networkd-dispatcher
 fi
index b2dda7a9933c011c801bf5cd819a4218e2b046e9..b3e1b69ebec757590248829703aa67a191c8608b 100755 (executable)
@@ -54,7 +54,6 @@ if [[ ! -e $dst && -e $src ]]; then
   mount -o bind $src $dst
 fi
 
-chmod 700 $target/mnt/root
 
 $FAI/distro-install-common/end
 
@@ -280,6 +279,7 @@ EOFOUTER
   exit 0 # avoid unnecessary stuff in bootstrap vol
 fi
 
+chmod 700 $target/mnt/root
 
 ## misc settings
 $ROOTCMD bash <<'EOFOUTER'
@@ -374,127 +374,7 @@ 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 | grep '/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
-
-# from packages listed in .github/workflows/devel.yml
-# The dumb makefile makes us build docs even if they were already built.
-if ! type -p sphinx-build &>/dev/null; then
-  $ROOTCMD apt-get -y install python3-sphinx-rtd-theme
-fi
-
-if ! type -p curl &>/dev/null; then
-  $ROOTCMD apt-get -y install curl
-fi
-if ! type -p wget &>/dev/null; then
-  $ROOTCMD apt-get -y install wget
-fi
-
-
-## If we need to use a dev version temporarily, this to true
-## and copy it over in fai-redep. See comment there.
-static_ver=false
-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
-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}')
-
-# todo: this doesn't account for multiple distros versions that require
-# their own builds.
-if [[ $ver != "$cur_ver" ]]; then
-  # Assumes we've pre-built the static_ver version if we are using that.
-  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}.btrfs /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}.btrfs /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, assumes we've built it
-    # outside the chroot and won't get into this case.
-    if [[ -e /b/distro-functions/src/package-manager-abstractions ]]; then
-      . /b/distro-functions/src/package-manager-abstractions
-      debian_codename=$(debian-codename)
-      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}.btrfs /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
+## end get new kernel and btrfs-progs ##
 
 
-  fi
-fi
-## end get new kernel and btrfs-progs ##
+. $FAI/distro-install-common/new-btrfs-progs
index d4a20e8b37c202468c005f5e526aa351b382e8f0..4ade1af14399045d80647b68d6f67c32af6b1a73 100755 (executable)
@@ -652,16 +652,16 @@ config rule
 
 
 config redirect
- option name temp_webserver
+ option name alt_ssh
  option src              wan
- option src_dport        8877
+ option src_dport        23
  option dest             lan
- option dest_ip          $l.38
+ option dest_ip          $l.34
  option proto            tcp
 config rule
  option src              wan
  option target           ACCEPT
- option dest_port        8877
+ option dest_port        23
  option proto            tcp