improvements
[automated-distro-installer] / fai / config / scripts / IANK / 11-iank
index 54641b237bcc10b15b30b90bb0f8b662253f8609..25c0503781e352e9de0d5515a5a7ae599ddcb7dc 100755 (executable)
@@ -24,6 +24,9 @@ if [[ $EUID != 0 ]]; then
   exit 1
 fi
 
   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 ! type -t fcopy &>/dev/null; then
   sudo apt-get -y install fai-client
 fi
@@ -166,14 +169,32 @@ EOF
 fi
 
 # use networkmanager if this host has wireless.
 fi
 
 # use networkmanager if this host has wireless.
-if [[ $(iw dev) ]]; then
+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
   $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.
 
   # in a default desktop install, it looks like netplan creates this file under
   # run/NetworkManager/conf.d in early boot.
 
@@ -185,12 +206,17 @@ EOF
 dns=systemd-resolved
 EOF
 
 dns=systemd-resolved
 EOF
 
-  $FAI/distro-install-common/ethusb-static
-  if [[ $(dig +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]] \
+
+  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
        && ip n show 10.2.0.1 | grep . &>/dev/null; then
-    : # we are at home. note: logic duplicated in btrbk-run
+    # we are at_home
+    $FAI/distro-install-common/ethusb-static $ethusb_arg
   else
   else
-    $FAI/distro-install-common/ethusb-nm
+    $FAI/distro-install-common/ethusb-static off $ethusb_arg
   fi
 
 
   fi
 
 
@@ -222,6 +248,7 @@ fi
 
 if ifclass LINODE; then
   mkdir -p $target/etc/initramfs-tools/conf.d
 
 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
   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
@@ -333,14 +360,21 @@ for g in plugdev audio video cdrom; do
   $ROOTCMD usermod -a -G $g user2
 done
 
   $ROOTCMD usermod -a -G $g user2
 done
 
-
 ## begin get new kernel and btrfs-progs ##
 case $HOSTNAME in
   sy|so)
 ## begin get new kernel and btrfs-progs ##
 case $HOSTNAME in
   sy|so)
-    $FAI/distro-install-common/install-stable-kernel-debs
+    # on sy t11, severe wifi degredation on 6.8
+    # on so t11, no x11 display on 6.8
+    $FAI/distro-install-common/install-mainline-kernel-debs stable
     ;;
   *)
     ;;
   *)
-    $ROOTCMD apt-get -y install linux-libre
+    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
 
     ;;
 esac