[debian-lan-devel] [debian-lan] 07/07: Simplify the setup of the chroots.

Andreas B. Mundt andi at moszumanska.debian.org
Fri Sep 12 16:23:27 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 62ab8838b329106303e3d4f8a4801057d64a1066
Author: Andreas B. Mundt <andi at debian.org>
Date:   Thu Sep 11 19:23:08 2014 +0200

    Simplify the setup of the chroots.
    
    The boot menu functionality is now implemented in di-netboot-assistant.
---
 .../usr/local/sbin/debian-lan-chroots/FAISERVER    | 74 +++++-----------------
 1 file changed, 16 insertions(+), 58 deletions(-)

diff --git a/fai/config/files/usr/local/sbin/debian-lan-chroots/FAISERVER b/fai/config/files/usr/local/sbin/debian-lan-chroots/FAISERVER
index ac4e921..4f4950a 100755
--- a/fai/config/files/usr/local/sbin/debian-lan-chroots/FAISERVER
+++ b/fai/config/files/usr/local/sbin/debian-lan-chroots/FAISERVER
@@ -14,6 +14,8 @@ DLROOT="/opt/live"
 . /etc/fai/fai.conf
 . /etc/fai/nfsroot.conf
 
+WS_TEMPLATE=$TFTPROOT/pxelinux.cfg/workstation.tmpl
+DL_TEMPLATE=$TFTPROOT/pxelinux.cfg/diskless.tmpl
 ##########
 
 check_network () {
@@ -26,20 +28,23 @@ check_network () {
 
 setup_nfsroot () {
     echo "Creating the nfsroot for FAI."
-    if [ ! -d $NFSROOT ] || [ -z "$(ls -A $NFSROOT)" ] ; then
-        fai-setup -f -e -v
-    else
+    if [ -x $NFSROOT/usr/bin/apt-get ] ; then
         ## Update nfsroot:
         fai-make-nfsroot -v -k
+    else
+        fai-setup -f -e -v
     fi
 
-    WS_TEMPLATE=$TFTPROOT/pxelinux.cfg/workstation.tmpl
     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*)`
 
+    ## Create links needed for di-netboot-installer:
+    [ -L $TFTPROOT/vmlinuz ]    || ln -vs $KERNEL $TFTPROOT/vmlinuz
+    [ -L $TFTPROOT/initrd.img ] || ln -vs $INITRD $TFTPROOT/initrd.img
+
     echo "Creating template with $KERNEL and $INITRD."
     cat > $WS_TEMPLATE <<EOF
 # template for workstation
@@ -62,7 +67,7 @@ EOF
     done
     echo -e " Done.\nCreated $NUM workstation configurations."
 
-    if [ -d $DLROOT ] ; then
+    if [ -e $DL_TEMPLATE ] ; then
         fai-chboot -vc diskless.tmpl default &>> /var/log/fai/fai-chboot.log
     else
         ## create default configuration (sysinfo):
@@ -74,16 +79,15 @@ EOF
 
 setup_diskless () {
     export LC_ALL=C
-    if [ ! -d $DLROOT ] || [ -z "$(ls -A $DLROOT)" ] ; then
-        fai -vNu diskless dirinstall $DLROOT
-    else
-        mount --bind /sys  $DLROOT/sys
-        mount --bind /proc $DLROOT/proc
+    if [ -x $DLROOT/usr/sbin/fai ] ; then
+        mount -t sysfs sysfs $DLROOT/sys
+        mount -t proc  proc  $DLROOT/proc
         chroot $DLROOT fai -vNu diskless softupdate
         umount $DLROOT/sys $DLROOT/proc
+    else
+        fai -vNu diskless dirinstall $DLROOT
     fi
 
-    DL_TEMPLATE=$TFTPROOT/pxelinux.cfg/diskless.tmpl
     if [ -e $DL_TEMPLATE ]; then
         cp -v $DL_TEMPLATE ${DL_TEMPLATE}_$(date +%F)
     fi
@@ -116,50 +120,6 @@ EOF
     fai-chboot -vc diskless.tmpl default &>> /var/log/fai/fai-chboot.log
 }
 
-
-setup_PXEinstaller () {
-    ## Add Debian PXE Installer.
-    ## Copy stuff, symlinks do not work (chroot environment):
-    cp -ru $INSTALLER $TFTPROOT
-
-    if [ -d $TFTPROOT/debian-installer/i386 ] ; then
-        KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
-        INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
-        ## add installer menu
-        cat >> $TFTPROOT/pxelinux.cfg/default <<EOF
-
-label Debian-LAN/FAI Roaming Machine
-kernel $KERNEL
-append initrd=$INITRD ip=dhcp root=nfs4:/nfsroot aufs FAI_FLAGS=verbose,sshd,createvt FAI_CONFIG_SRC=$FAI_CONFIG_SRC FAI_ACTION=install
-
-menu title Boot menu
-menu background debian-installer/i386/boot-screens/splash.png
-menu color title        * #FFFFFFFF *
-menu color border       * #00000000 #00000000 none
-menu color sel          * #ffffffff #76a1d0ff *
-menu color hotsel       1;7;37;40 #ffffffff #76a1d0ff *
-menu color tabmsg       * #ffffffff #00000000 *
-menu color help         37;40 #ffdddd00 #00000000 none
-menu vshift 16
-menu rows 7
-menu helpmsgrow 12
-menu cmdlinerow 12
-menu tabmsgrow 13
-default debian-installer/i386/boot-screens/vesamenu.c32
-timeout 150
-prompt 0
-noescape 1
-
-label Debian Installer i386
-        config debian-installer/i386/pxelinux.cfg/default
-
-label Debian Installer amd64
-        config debian-installer/amd64/pxelinux.cfg/default
-EOF
-    fi
-}
-
-
 #########################
 ## 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
@@ -169,20 +129,18 @@ read -e -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##
 
-if [ -d $NFSROOT ] && [ -n "$(ls -A $NFSROOT)" ] ; then
+if [ -e $NFSROOT/.THIS_IS_THE_FAI_NFSROOT ] ; then
     ## Setup/update chroot for diskless machines:
     read -e -n 1 -p "Install/update the chroot for diskless clients now? [y|N]: " inp
     if [ "$inp" = "y" ] ; then
         check_network
         setup_diskless
-        setup_PXEinstaller
     fi
 fi
 

-- 
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