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