[debian-lan-devel] [debian-lan] 03/03: Improve the setup of the chroots for FAI and diskless machines.
Andreas B. Mundt
andi at moszumanska.debian.org
Sat Jun 14 13:10:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
andi pushed a commit to branch master
in repository debian-lan.
commit 56bc27de5e7f5d8591b561e87f0a52980186cf96
Author: Andreas B. Mundt <andi at debian.org>
Date: Sat Jun 14 14:39:23 2014 +0200
Improve the setup of the chroots for FAI and diskless machines.
Add the possibility to update the chroots.
---
fai/config/files/etc/rc.local/FAISERVER | 81 +++++++++++++++++----------------
1 file changed, 42 insertions(+), 39 deletions(-)
diff --git a/fai/config/files/etc/rc.local/FAISERVER b/fai/config/files/etc/rc.local/FAISERVER
index eb1eff8..da33c61 100755
--- a/fai/config/files/etc/rc.local/FAISERVER
+++ b/fai/config/files/etc/rc.local/FAISERVER
@@ -28,15 +28,23 @@ check_network () {
setup_nfsroot () {
echo "Creating the nfsroot for FAI."
trap "rc=$?; rm -rf $NFSROOT; exit $rc" ERR SIGHUP SIGINT SIGTERM
- fai-setup -e -v
+ if [ ! -d $NFSROOT ] ; then
+ fai-setup -e -v
+ else
+ ## Update nfsroot:
+ fai-make-nfsroot -v -k
+ fi
trap - ERR SIGHUP SIGINT SIGTERM
+
WS_TEMPLATE=$TFTPROOT/pxelinux.cfg/workstation.tmpl
- if [ ! -e $WS_TEMPLATE ]; then
- KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
- INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
+ if [ -e $WS_TEMPLATE ]; then
+ cp -v $WS_TEMPLATE ${WS_TEMPLATE}_$(date +%F)
+ fi
+ KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
+ INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
- echo "Creating template with $KERNEL and $INITRD."
- cat > $WS_TEMPLATE <<EOF
+ echo "Creating template with $KERNEL and $INITRD."
+ cat > $WS_TEMPLATE <<EOF
# template for workstation
default Debian-LAN workstation
@@ -44,9 +52,7 @@ label Debian-LAN workstation
kernel $KERNEL
append initrd=$INITRD ip=dhcp root=nfs4:/$(basename $NFSROOT) aufs FAI_FLAGS=verbose,sshd,createvt FAI_CONFIG_SRC=nfs://faiserver/config FAI_ACTION=install
EOF
- else
- echo "The template $WS_TEMPLATE exists already!"
- fi
+
## Create pxelinux boot configuration for workstationXX.
## The seq range is sed from the corresponding variable
## when fcopy'd:
@@ -72,16 +78,22 @@ EOF
setup_diskless () {
export LC_ALL=C
trap "rc=$?; rm -rf $DLROOT; exit $rc" ERR SIGHUP SIGINT SIGTERM
- fai -vNu diskless dirinstall $DLROOT
+ if [ ! -d $DLROOT ] ; then
+ fai -vNu diskless dirinstall $DLROOT
+ else
+ chroot $DLROOT fai -vNu diskless softupdate
+ fi
trap - ERR SIGHUP SIGINT SIGTERM
DL_TEMPLATE=$TFTPROOT/pxelinux.cfg/diskless.tmpl
- if [ ! -e $DL_TEMPLATE ]; then
- KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
- INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
+ if [ -e $DL_TEMPLATE ]; then
+ cp -v $DL_TEMPLATE ${DL_TEMPLATE}_$(date +%F)
+ fi
+ KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
+ INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
- echo "Creating template with $KERNEL and $INITRD."
- cat > $DL_TEMPLATE <<EOF
+ echo "Creating template with $KERNEL and $INITRD."
+ cat > $DL_TEMPLATE <<EOF
# template for diskless
default Debian-LAN/FAI Live System
@@ -89,9 +101,6 @@ label Debian-LAN/FAI Live System
kernel $KERNEL
append initrd=$INITRD ip=dhcp root=nfs4:/$(basename $DLROOT) aufs
EOF
- else
- echo "The template $DL_TEMPLATE exists already!"
- fi
## Create pxelinux boot configuration for disklessXX.
## The seq range is sed from the corresponding variable
@@ -157,47 +166,41 @@ EOF
## Add missing plugins to munin, the line will be commented afterwards:
munin-node-configure --shell 2>/dev/null | sh && sed -i "s%\(^munin-node-configure\)%\#\1%" $0
-## Setup nfsroot for FAI:
-if [ ! -d $NFSROOT ] ; then
- cat <<EOF
+## Setup/update nfsroot for FAI:
+cat <<EOF
================================================================================
-The nfsroot for FAI may be created by executing $0.
+The nfsroot for FAI may be created/updated by executing $0.
This can be done now, later or manually.
Internet access is needed to download packages.
If unanswered, this script will exit after $TIMEOUT seconds.
EOF
- read -e -t $TIMEOUT -n 1 -p "Install the nfsroot for FAI now? [y|N]: " inp
- if [ "$inp" = "y" ] ; then
- check_network
- setup_nfsroot
- setup_PXEinstaller
- else
- exit 0
- fi
+read -e -t $TIMEOUT -n 1 -p "Install/update the nfsroot for FAI now? [y|N]: " inp
+if [ "$inp" = "y" ] ; then
+ check_network
+ setup_nfsroot
+ setup_PXEinstaller
fi
## The following code is activated if diskless machines
## are to be served. Do not change the following line:
exit 0 ##DISKLESS_SERVER##
-## Setup chroot for diskless machines:
-if [ ! -d $DLROOT ] ; then
+if [ -d $NFSROOT ] ; then
+ ## Setup/update chroot for diskless machines:
cat <<EOF
================================================================================
-To install the chroot for diskless clients execute:
- export LC_ALL=C
- fai -vNu diskless dirinstall $DLROOT
-This can be done right now or manually.
+The chroot for diskless clients may be installed/updated.
+This can be done right now, later or manually by executing $0.
If unanswered, this script will exit after $TIMEOUT seconds.
EOF
- read -e -t $TIMEOUT -n 1 -p "Install the chroot for diskless clients now? [y|N]: " inp
+ read -e -t $TIMEOUT -n 1 -p "Install/update the chroot for diskless clients now? [y|N]: " inp
if [ "$inp" = "y" ] ; then
check_network
setup_diskless
setup_PXEinstaller
- else
- exit 0
fi
fi
+
+exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/debian-lan.git
More information about the debian-lan-devel
mailing list