3 # setup script that is only run once at boot time
4 # set up an FAI install server
13 nic
=$
(awk '/iface/ {print $2}' /etc
/network
/interfaces |
egrep -v ^lo
)
15 # regenerate ssh_host keys
16 ls /etc
/ssh
/ssh_host_
* > /dev
/null
18 dpkg-reconfigure
-fnoninteractive openssh-server
21 [ -x /etc
/init.d
/nscd
] && invoke-rc.d nscd restart
23 echo "================================="
24 echo "Setting up the FAI install server"
25 echo "This will take a few minutes"
26 echo "================================="
29 .
/etc
/fai
/nfsroot.conf
31 # copy the simple examples and pimp my config space
32 if [ ! -d "$FAI_CONFIGDIR/class" ]; then
33 mkdir
-p $FAI_CONFIGDIR
34 cp -a /usr
/share
/doc
/fai-doc
/examples
/simple
/* $FAI_CONFIGDIR
35 ainsl
/srv
/fai
/config
/class
/FAIBASE.var
"^LOGUSER=fai"
36 myip
=$
(ip addr show up|
grep -w inet | cut
-d t
-f 2 | cut
-d ' ' -f 2 | cut
-d / -f 1 |
grep -v 127.0.0.1)
37 echo "APTPROXY=http://$myip:3142" >> /srv
/fai
/config
/class
/DEBIAN.var
39 # set the LOGUSER, wo we get all the logs from our install clients
40 ainsl
/etc
/fai
/fai.conf
"^LOGUSER=fai"
42 # make index, then import the packages from the CD mirror
43 apt-get update
>/dev
/null
44 curl
-fs 'http://127.0.0.1:3142/acng-report.html?doImport=Start+Import&calcSize=cs&asNeeded=an#bottom' >/dev
/null
46 # setup the FAI server, including creating the nfsroot, use my own proxy
47 export APTPROXY
="http://127.0.0.1:3142"
48 if [ -f /var
/tmp
/base.
tar.xz
]; then
49 fai-setup
-fvB /var
/tmp
/base.
tar.xz
> /var
/log
/fai
/fai-setup.log
2>&1
51 fai-setup
-fv > /var
/log
/fai
/fai-setup.log
2>&1
54 rm /var
/tmp
/base.
tar.xz
56 echo "================================================"
57 echo -e "Setting up the FAI server was ${GREEN}successful${NORMAL}"
58 echo "================================================"
63 echo "=================================================="
64 echo -e "${RED}ERROR${NORMAL}: Setting up the FAI install server ${RED}FAILED${NORMAL}!"
65 echo "Read /var/log/fai/fai-setup.log for more debugging"
66 echo "=================================================="
72 cat <<EOF >> /srv/fai/nfsroot/etc/fai/fai.conf
73 # use short hostname instead of FQDN
74 export HOSTNAME=\${HOSTNAME%%.*}
75 echo \$HOSTNAME > /proc/sys/kernel/hostname
78 # create default pxelinux boot configuration
81 # create a template for booting the installation
82 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config jessie.tmpl
84 # Since we do not know the MAC address, our DHCP cannot provide the hostname.
85 # Therefore we do explicitly set the hostname
86 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=xfcehost xfcehost
87 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=demohost demohost
89 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=client
$c client
$c
92 fai-monitor
> /var
/log
/fai
/fai-monitor.log
&
97 # create new rc.local for next reboot
98 echo '#! /bin/bash' > /etc
/rc.
local
99 echo 'fai-monitor > /var/log/fai/fai-monitor.log &' >> /etc
/rc.
local
100 chmod a
+rx
/etc
/rc.
local