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
24 echo "================================="
25 echo "Setting up the FAI install server"
26 echo "This will take a few minutes"
27 echo "================================="
30 .
/etc
/fai
/nfsroot.conf
32 # copy the simple examples and pimp my config space
33 if [ ! -d "$FAI_CONFIGDIR/class" ]; then
34 mkdir
-p $FAI_CONFIGDIR
35 cp -a /usr
/share
/doc
/fai-doc
/examples
/simple
/* $FAI_CONFIGDIR
36 ainsl
/srv
/fai
/config
/class
/FAIBASE.var
"^LOGUSER=fai"
37 _nic
=$
(ip route |
awk '/^default/ {print $5}'|
head -1)
38 myip
=$
(ip
-br ad sh
$_nic |
awk '{print $3}')
40 echo "APTPROXY=http://$myip:3142" >> /srv
/fai
/config
/class
/DEBIAN.var
42 # set the LOGUSER, wo we get all the logs from our install clients
43 ainsl
/etc
/fai
/fai.conf
"^LOGUSER=fai"
45 # make index, then import the packages from the CD mirror
46 /etc
/init.d
/apt-cacher-ng restart
47 apt-get update
>/dev
/null
48 echo "Importing local packages to apt cache"
49 curl
-fs 'http://127.0.0.1:3142/acng-report.html?doImport=Start+Import&calcSize=cs&asNeeded=an#bottom' >/dev
/null
50 echo "Creating FAI Server setup"
52 # setup the FAI server, including creating the nfsroot, use my own proxy
53 export APTPROXY
="http://127.0.0.1:3142"
54 if [ -f /var
/tmp
/base.
tar.xz
]; then
55 fai-setup
-fvB /var
/tmp
/base.
tar.xz
> /var
/log
/fai
/fai-setup.log
2>&1
57 fai-setup
-fv > /var
/log
/fai
/fai-setup.log
2>&1
60 rm /var
/tmp
/base.
tar.xz
62 echo "================================================"
63 echo -e "Setting up the FAI server was ${GREEN}successful${NORMAL}"
64 echo "================================================"
69 echo "=================================================="
70 echo -e "${RED}ERROR${NORMAL}: Setting up the FAI install server ${RED}FAILED${NORMAL}!"
71 echo "Read /var/log/fai/fai-setup.log for more debugging"
72 echo "Setup script is now moved to /var/tmp/$0"
73 echo "=================================================="
81 cat <<EOF >> /srv/fai/nfsroot/etc/fai/fai.conf
82 # use short hostname instead of FQDN
83 export HOSTNAME=\${HOSTNAME%%.*}
84 echo \$HOSTNAME > /proc/sys/kernel/hostname
87 # create default pxelinux boot configuration
90 # create a template for booting the installation
91 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config bookworm.tmpl
93 # Since we do not know the MAC address, our DHCP cannot provide the hostname.
94 # Therefore we do explicitly set the hostname
95 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=xfcehost xfcehost
96 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=demohost demohost
98 fai-chboot
-Iv -f verbose
,sshd
,createvt
,menu
-u nfs
://faiserver
/srv
/fai
/config
-k hostname
=client
$c client
$c
101 fai-monitor
> /var
/log
/fai
/fai-monitor.log
&
106 # create new rc.local for next reboot
107 echo '#! /bin/bash' > /etc
/rc.
local
108 echo 'fai-monitor > /var/log/fai/fai-monitor.log &' >> /etc
/rc.
local
109 chmod a
+rx
/etc
/rc.
local