#!/bin/bash
-# initial setup of a fai server on debian
+# Initial setup of a fai server on debian. works on localhost.
+# Set's the current ip as the tftp server. I vaguely remember
+# that using a hostname does not work
+# Requires changing dns to point faiserver and running fai-redep
set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@"
for pkg in $deps; do
dpkg -s $pkg &>/dev/null && continue ||:
to_install+=($pkg)
- echo $pkg >> /etc/fai/fai-manually-installed-packages
+ echo $pkg >>/etc/fai/fai-manually-installed-packages
done
if [[ $to_install ]]; then
apt-get -y install ${to_install[@]}
# Add debug to -f flag for more verbose output.
std_arg="-u nfs://faiserver/srv/fai/config"
-fai-chboot -Iv $std_arg default # reset so we are idempotent
+e fai-chboot -Iv $std_arg default # reset so we are idempotent
kernel=$(fai-chboot -L '^default$' | awk '{print $3}')
type -t host &>/dev/null || apt-get -y install dnsutils
+# resolve host using gateway address
my_ip=$(host faiserver $(route -n | sed -rn 's/^(0\.){3}0\s+(\S+).*/\2/p') | \
sed -rn 's/^\S+ has address //p')
k_args=$(fai-chboot -L '^default$' | \