#! /bin/bash

# setup script that is only run once at boot time

echo "Creating the nfsroot for FAI."

. /etc/fai/fai.conf
. /etc/fai/make-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
dhclient eth0  # connection to the outside world (hopefully)
ip addr add 192.168.1.250 dev eth0 # (fixed address of faiserver)
/etc/init.d/nscd restart
/etc/init.d/apache2 restart

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
