3 x
="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
9 echo "see help from myfai-chboot"
19 [[ $EUID == 0 ]] ||
exec sudo
"${BASH_SOURCE}" "$@"
21 e
() { echo "$@"; "$@"; }
25 type -t host &>/dev
/null || apt-get
-y install dnsutils
26 gateway_if
=$
(ip route |
sed -rn 's/^default via \S+ dev (\S+) .*/\1/p')
27 if [[ ! $gateway_if ]]; then
28 echo "$0: failed to find gateway interface"
31 # assuming ipv4, or else we might need to deal with multiple addresses
32 # in an ipv4 + ipv6 network.
33 network
=$
(ip
-4 -o a show dev
$gateway_if |
sed -rn '/scope.*global/s/^(\S+\s+){3}(\S+)\s.*/\2/p')
34 if [[ ! $network ]]; then
35 echo "$0: failed to find network"
39 if [[ $host == default
]]; then
42 ip
=$
(host $host |
sed -rn 's/^\S+ has address //p;T;q')/32
46 # alternate way of getting my ip
47 #gateway_ip=$(ip route | sed -rn 's/^default via (\S+) .*/\1/p')
48 #my_ip=$(host faiserver $gateway_ip | sed -rn 's/^\S+ has address //p;T;q')
50 if modprobe nfsd
&>/dev
/null
; then
51 std_arg
="-u nfs://faiserver/srv/fai/config"
52 root_arg
="$my_ip:/srv/fai/nfsroot"
53 # fai-setup without -e sets the ip to the local_ip/local_network, eg 192.168.1.3/24
54 # I restrict it to one ip as simple but imperfect access control.
55 sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc
/exports
56 cat >>/etc
/exports
<<EOF
57 /srv/fai/config $ip(async,ro,no_subtree_check)
58 /srv/fai/nfsroot $ip(async,ro,no_subtree_check,no_root_squash)
62 std_arg
="-u http://faiserver:8080/config.tar.gz"
63 root_arg
="live:http://faiserver:8080/squash.img"
64 /a
/exe
/web-conf
-i -p 8080 - apache2 faiserver
<<EOF
72 rm -f /srv
/tftp
/fai
/pxelinux.cfg
/*
78 # man page doesn't explain this, but this deletes & thus disables
80 e fai-chboot
-${fai_action_arg}v
$std_arg default
# set it to default to get a val out of it next
81 kernel
=$
(fai-chboot
-L '^default$' |
awk '{print $3}')
82 default_k_args
=$
(fai-chboot
-L '^default$' | \
83 sed -r "s/^(\S+\s+){3}(.*)/\2/")
84 # example of default_k_args
85 # initrd=initrd.img-3.16.0-4-amd64 ip=dhcp root=192.168.1.3:/srv/fai/nfsroot aufs FAI_CONFIG_SRC=nfs://faiserver/srv/fai/config FAI_ACTION=install
88 for arg
in $default_k_args; do
90 # default root arg is /srv/fai/nfsroot
91 root
=*) k_args
+=(root
=$root_arg) ;;
95 rm -f /srv
/tftp
/fai
/pxelinux.cfg
/*
96 e fai-chboot
-k "${k_args[*]}" -v -f verbose
,sshd
,createvt
$fai_reboot_arg $std_arg $kernel "$host"