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 _nic
=$
(ip route |
awk '/^default/ {print $5}'|
head -1)
39 myip
=$
(ip
-br ad sh
$_nic |
awk '{print $3}')
41 echo "APTPROXY=http://$myip:3142" >> /srv
/fai
/config
/class
/DEBIAN.var
43 # set the LOGUSER, wo we get all the logs from our install clients
44 ainsl
/etc
/fai
/fai.conf
"^LOGUSER=fai"
46 # make index, then import the packages from the CD mirror
47 apt-get update
>/dev
/null
48 curl
-fs 'http://127.0.0.1:3142/acng-report.html?doImport=Start+Import&calcSize=cs&asNeeded=an#bottom' >/dev
/null
50 # setup the FAI server, including creating the nfsroot, use my own proxy
51 export APTPROXY
="http://127.0.0.1:3142"
52 if [ -f /var
/tmp
/base.
tar.xz
]; then
53 fai-setup
-fvB /var
/tmp
/base.
tar.xz
> /var
/log
/fai
/fai-setup.log
2>&1
55 fai-setup
-fv > /var
/log
/fai
/fai-setup.log
2>&1
58 rm /var
/tmp
/base.
tar.xz
60 echo "================================================"
61 echo -e "Setting up the FAI server was ${GREEN}successful${NORMAL}"
62 echo "================================================"
67 echo "=================================================="
68 echo -e "${RED}ERROR${NORMAL}: Setting up the FAI install server ${RED}FAILED${NORMAL}!"
69 echo "Read /var/log/fai/fai-setup.log for more debugging"
70 echo "=================================================="
76 cat <<EOF >> /srv/fai/nfsroot/etc/fai/fai.conf
77 # use short hostname instead of FQDN
78 export HOSTNAME=\${HOSTNAME%%.*}
79 echo \$HOSTNAME > /proc/sys/kernel/hostname
82 # create default pxelinux boot configuration
85 # create a template for booting the installation
86 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config bullseye.tmpl
88 # Since we do not know the MAC address, our DHCP cannot provide the hostname.
89 # Therefore we do explicitly set the hostname
90 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=xfcehost xfcehost
91 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=demohost demohost
93 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=client
$c client
$c
96 fai-monitor
> /var
/log
/fai
/fai-monitor.log
&
101 # create new rc.local for next reboot
102 echo '#! /bin/bash' > /etc
/rc.
local
103 echo 'fai-monitor > /var/log/fai/fai-monitor.log &' >> /etc
/rc.
local
104 chmod a
+rx
/etc
/rc.
local