#! /bin/bash

# setup script that is only run once at boot time

echo ""
echo "Setting up the FAI install server"
echo ""
sleep 5

. /etc/fai/fai.conf
. /etc/fai/nfsroot.conf

if [ ! -d "$FAI_CONFIGDIR/class" ]; then
    mkdir -p $FAI_CONFIGDIR
    cp -a /usr/share/doc/fai-doc/examples/simple/* $FAI_CONFIGDIR
fi

# setup network
ip addr add 192.168.33.250/24 dev eth0 # (fixed address of faiserver)
dhclient eth0  # connection to the outside world (hopefully)
[ -x /etc/init.d/nscd ] && /etc/init.d/nscd restart
/etc/init.d/apache2 restart

# do not call fai-setup currently
echo 'Please call fai-setup -v 2>&1 | tee /var/log/fai-setup.log'

fai-setup -v 2>&1 | tee /var/log/fai-setup.log

# create default pxelinux boot configuration (boot from local disk)
fai-chboot -o default

#echo "Log files are saved to /var/log/fai-setup.log"

# remove me
rm $0
exit 0
