4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
8 echo "see help from myfai-chboot"
13 [[ $EUID == 0 ]] ||
exec sudo
"${BASH_SOURCE}" "$@"
15 e
() { echo "$@"; "$@"; }
19 type -t host &>/dev
/null || apt-get
-y install dnsutils
20 ip
=$
(host $host |
sed -rn 's/^\S+ has address //p;T;q')
21 gateway_ip
=$
(route
-n |
sed -rn 's/^0\.0\.0\.0\s+(\S+).*/\1/p')
22 my_ip
=$
(host faiserver
$gateway_ip |
sed -rn 's/^\S+ has address //p;T;q')
24 if modprobe nfsd
&>/dev
/null
; then
25 std_arg
="-u nfs://faiserver/srv/fai/config"
26 root_arg
="$my_ip:/srv/fai/nfsroot"
27 # fai-setup without -e sets the ip to the local_ip/local_network, eg 192.168.1.3/24
28 # I restrict it to one ip as simple but imperfect access control.
29 sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc
/exports
30 cat >>/etc
/exports
<<EOF
31 /srv/fai/config $ip/32(async,ro,no_subtree_check)
32 /srv/fai/nfsroot $ip/32(async,ro,no_subtree_check,no_root_squash)
36 std_arg
="-u http://faiserver:8080/config.tar.gz"
37 root_arg
="live:http://faiserver:8080/squash.img"
38 /a
/exe
/apache-site
-i -p 8080 - faiserver
<<EOF
46 rm -f /srv
/tftp
/fai
/pxelinux.cfg
/*
52 # man page doesn't explain this, but this deletes & thus disables
54 e fai-chboot
-Iv $std_arg default
# set it to default to get a val out of it next
55 kernel
=$
(fai-chboot
-L '^default$' |
awk '{print $3}')
56 default_k_args
=$
(fai-chboot
-L '^default$' | \
57 sed -r "s/^(\S+\s+){3}(.*)/\2/")
58 # example of default_k_args
59 # 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
62 for arg
in $default_k_args; do
64 # default root arg is /srv/fai/nfsroot
65 root
=*) k_args
+=(root
=$root_arg) ;;
69 rm -f /srv
/tftp
/fai
/pxelinux.cfg
/*
70 e fai-chboot
-k "${k_args[*]}" -v -f verbose
,sshd
,createvt
,reboot
$std_arg $kernel "$host"