static usb ethnet addresses
[automated-distro-installer] / lk
diff --git a/lk b/lk
old mode 100644 (file)
new mode 100755 (executable)
index 7715fda..b757fcc
--- a/lk
+++ b/lk
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 usage() {
-    cat <<EOF
-Usage: ${0##*/} [-h|--help]
+  cat <<EOF
+Usage: ${0##*/} [-h|--help] [HOST]
 fai kexec from upstream live cds, i.e. curl|bash
 
+If HOST argument, ssh to root@HOST before doing kexec. This does what
+pxe would do, but skipping boot sequence up to and including the pxe
+dhcp.
+
+
 You can copy this to a http server, then wget -O- url|sudo bash
 curl is sometimes not preinstalled on a live cd.
 
@@ -28,34 +33,40 @@ Alternative to http server:
 2. On another machine nc INSTALL_MACHINE 1234 <live-kexec
 Obviously beware that anyone on your network could send commands to the install machine.
 
-This has been tested on trisquel 7 & 8 & ubuntu 16.04 & 18.10.
-With 18.10 on an x200, kexec was unreliable, resulting in freezes and
-kernel panics.
+This has been tested on trisquel 7 & 8 & ubuntu 16.04 & 18.10.  With
+18.10 and trisquel 8 on an x200, kexec was unreliable, resulting in
+freezes and kernel panics. On t11, linux 5.15.0-40-generic, after kexec,
+black screen, ping worked but nothing else. Debian 11 live image worked.
 
 If the screen just sits in a weird color inverted, corrupted looking state,
 it's probably nothing wrong with the computer, but a problem
 with the fai server. If you can do this from a virtual terminal,
 it will print out more info (I know from running it on a vm).
 EOF
-    exit $1
+  exit $1
 }
 case $1 in
-    -h|--help) usage ;;
+  -h|--help) usage ;;
+  ?*) host=$1
 esac
 
+if [[ $host ]]; then
+  ssh root@$host bash -s < $(readlink -f "$BASH_SOURCE")
+  exit $?
+fi
 
 set -ex
 if grep -q ID=ubuntu /etc/os-release; then
-    # add universe, pxe-kexec is there
-    sed -ri '/^\s*deb/{/universe/!s/$/ universe/}' /etc/apt/sources.list
+  # add universe, pxe-kexec is there
+  sed -ri '/^\s*deb/{/universe/!s/$/ universe/}' /etc/apt/sources.list
 fi
 if ! type -p pxe-kexec >/dev/null 2>&1; then
-    apt-get update
-    apt-get install -y debconf
-    debconf-set-selections <<EOF
+  apt-get update ||: # try even if we fail
+  apt-get install -y debconf
+  debconf-set-selections <<EOF
 kexec-tools kexec-tools/load_kexec boolean false
 EOF
-    apt-get install -y pxe-kexec
+  apt-get install -y pxe-kexec
 fi
 # running this piped to bash on belenos, the apt-get goes
 # into the background while it's still installing, and pxe-kexec