+host=$1
+
+type -t host &>/dev/null || apt-get -y install dnsutils
+ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q')
+gateway_ip=$(route -n | sed -rn 's/^0\.0\.0\.0\s+(\S+).*/\1/p')
+my_ip=$(host faiserver $gateway_ip | sed -rn 's/^\S+ has address //p;T;q')
+
+if modprobe nfsd &>/dev/null; then
+ std_arg="-u nfs://faiserver/srv/fai/config"
+ root_arg="$my_ip:/srv/fai/nfsroot"
+ # fai-setup without -e sets the ip to the local_ip/local_network, eg 192.168.1.3/24
+ # I restrict it to one ip as simple but imperfect access control.
+ sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc/exports
+ cat >>/etc/exports <<EOF
+/srv/fai/config $ip/32(async,ro,no_subtree_check)
+/srv/fai/nfsroot $ip/32(async,ro,no_subtree_check,no_root_squash)
+EOF
+ exportfs -ra
+else
+ std_arg="-u http://faiserver:8080/config.tar.gz"
+ root_arg="live:http://faiserver:8080/squash.img"
+ /a/exe/apache-site -i -p 8080 - faiserver <<EOF
+<Location />
+ Deny from all
+ Allow from $ip
+</Location>
+EOF
+fi