sed -r 's/^Depends:|,|\|[^,]+|isc-dhcp-server//g')
sed -i 's/^#deb/deb/' /etc/fai/apt/sources.list
sed -i 's/#LOGUSER/LOGUSER/' /etc/fai/fai.conf
-fai-setup -v
+# from man fai-make-nfsroot,
+# figured out after partitioning ignored my crypt partition
+if ! grep cryptsetup /etc/fai/NFSROOT &>/dev/null; then
+ sed -ri '/^PACKAGES install$/a cryptsetup' /etc/fai/NFSROOT
+fi
+fai-setup -vf
{ head -n 1 /srv/fai/nfsroot/root/.ssh/known_hosts | awk '{print $1}' \
| tr '\n' ' '; ssh-keyscan localhost | grep -o "ecdsa-sha2-nistp256.*"; \
} >>/srv/fai/nfsroot/root/.ssh/known_hosts
-# from config machine. todo: clean this up.
+# this does not alter the config on a new install
sed -ri 's#^([[:space:]]*TFTP_DIRECTORY[[:space:]]*=).*#\1"/srv/tftp"#' \
/etc/default/tftpd-hpa
std_arg="-u nfs://faiserver/srv/fai/config"
fai-chboot -Iv $std_arg default
kernel=$(fai-chboot -L '^default$' | awk '{print $3}')
-my_ip=$(getent hosts faiserver | awk '{ print $1 }')
+type -t host &>/dev/null || apt-get -y install dnsutils
+my_ip=$(host faiserver $(route -n | sed -rn 's/^(0\.){3}0\s+(\S+).*/\2/p') | \
+ sed -rn 's/^faiserver has address //p')
k_args=$(fai-chboot -L '^default$' | \
sed -r "s/^(\S+\s+){3}(.*root=)(.*)/\2$my_ip:\3/")
fai-chboot -k "$k_args" -v -f verbose,sshd,createvt,reboot $std_arg $kernel default
# make the faiserver also the apt proxy server
-apt-get install apt-cacher-ng
+apt-get -y install apt-cacher-ng
# background on choosing apt-cacher-ng:
# googling around a bit finds 2 main solutions:
# http://askubuntu.com/questions/3503/best-way-to-cache-apt-downloads-on-a-lan
# apt-cacher-ng doesn't have zeroconf.
-# so I'm not sure how smart it will be if the server goes down.
# It touts having minimal dependencies, but I don't care.
# The downside to squid-deb-proxy is that it's config is for specific repos,
# you have to add all the repos you use.
# random fai note: as far as I can tell, profiles are just for putting
# in a selectable boot menu, which I don't want.
-if [[ ! -e ~/.ssh/id_rsa.pub ]]; then
- ssh-keygen -t rsa -N ''
-fi
-x=$(mktemp); ssh -F /dev/null -oUserKnownHostsFile=$x localhost :
-cat x | tee -a /srv/fai/nfsroot/root/.ssh/known_hosts
+# somewhere I call it faiserver, but debian's default is faiserver.lan
+sed -ri 's/faiserver.lan/faiserver/' /srv/fai/nfsroot/root/.ssh/known_hosts