more aramo/jammy updates
[automated-distro-installer] / myfai-chboot
1 #!/bin/bash
2
3 set -eE -o pipefail
4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5
6 x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
7
8 usage() {
9 cat <<EOF
10 usage: ${0##*/} [OPTIONS] [HOSTNAME|IP|default]
11
12 Sets up tftp pxe config and nfs server on host "faiserver".
13
14 If our kernel has no nfs support, uses apache intead of nfs, and depends
15 on another repo of Ian Kelling, basic-https-conf, where the file is at
16 /a/exe/web-conf.
17
18 Usng this, you can boot into fai with pxe-kexec without changing
19 the dhcp server.
20
21 Argument sets the host to enable it for. No argument disables pxe
22 config for all hosts, but leaves nfs server alone. Use faiserver-disable
23 to disable the nfs server.
24
25 -S sets FAI_ACTION=sysinfo, and remove fai flag reboot.
26 Usefull for doing a system recovery. It reboots automatically anyways :(
27 -k Add serial port output for kgped16
28 -i sets FAI_ACTION=inventory and remove fai flag reboot.
29 I'm not sure what this is usefull for.
30 -h|--help Print help and exit.
31
32 EOF
33 exit $1
34 }
35 case $1 in
36 -h|--help) usage ;;
37 esac
38
39
40 faiserver_addr=$(host faiserver | sed -rn 's/^\S+ has address //p;T;q' ||:)
41 host=$(./chost faiserver)
42 if ip a | grep "^ *inet.\? $faiserver_addr" &>/dev/null; then
43 ./myfai-chboot-local "$@"
44 else
45 ssh root@$host bash -s -- "$@" <myfai-chboot-local
46 fi