[debian-lan-devel] [SCM] Debian-LAN development and packaging branch, master, updated. 0.6-52-g84c6598

Andreas B. Mundt andi at debian.org
Mon Oct 29 12:16:27 UTC 2012


The following commit has been merged in the master branch:
commit 84c6598a3282b134d90c8c14ecd2c6967ad205e0
Author: Andreas B. Mundt <andi at debian.org>
Date:   Sun Oct 28 17:06:54 2012 +0100

    Improved and restructured rc.local.
    
    Make sure that setting up the chroots for FAI and for diskless
    machines works independently.  Trap errors.

diff --git a/fai/config/files/etc/rc.local/FAISERVER b/fai/config/files/etc/rc.local/FAISERVER
index e150ef9..63667b8 100755
--- a/fai/config/files/etc/rc.local/FAISERVER
+++ b/fai/config/files/etc/rc.local/FAISERVER
@@ -25,7 +25,9 @@ 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 -l
+    trap - ERR SIGHUP SIGINT SIGTERM
     ## Create pxelinux boot configuration for workstationXX.
     ## The seq range is sed from the corresponding variable
     ## when fcopy'd:
@@ -36,18 +38,59 @@ setup_nfsroot () {
 	NUM=$(($NUM+1))
     done
 
-    ## create default configuration (sysinfo):
-    fai-chboot -Svu $FAI_CONFIG_SRC default
+    if [ -d $DLROOT ] ; then
+	fai-chboot -vc diskless.tmpl default
+    else
+        ## create default configuration (sysinfo):
+	fai-chboot -Svu $FAI_CONFIG_SRC default
+    fi
+}
+
+
+setup_diskless () {
+    export LC_ALL=C
+    trap "rc=$?; rm -rf $DLROOT; exit $rc" ERR SIGHUP SIGINT SIGTERM
+    fai -vNu diskless dirinstall $DLROOT/filesystem.dir/
+    trap - ERR SIGHUP SIGINT SIGTERM
+
+    TEMPLATE=$TFTPROOT/pxelinux.cfg/diskless.tmpl
+    if [ ! -e $TEMPLATE ]; then
+	KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
+	INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
+
+	echo "Creating template with $KERNEL and $INITRD."
+	cat > $TEMPLATE <<EOF
+# template for diskless
+default fai-generated
+
+label fai-generated
+kernel $KERNEL
+append initrd=$INITRD ip=dhcp root=/dev/nfs nfsroot=/opt boot=live
+EOF
+    else
+	echo "The template $TEMPLATE exists already!"
+    fi
+
+    ## Create pxelinux boot configuration for disklessXX.
+    ## The seq range is sed from the corresponding variable
+    ## when fcopy'd:
+    NUM=0
+    for i in `seq DL_RANGE` ; do
+	NUMSTR=`printf "%02d" $NUM`
+	fai-chboot -vc diskless.tmpl diskless$NUMSTR  2>&1 | tee -a /var/log/fai/fai-chboot.log
+	NUM=$(($NUM+1))
+    done
+
+    ## Boot unknown machines as diskless:
+    fai-chboot -vc diskless.tmpl default
 }
 
+
 setup_PXEinstaller () {
     ## Add Debian PXE Installer.
     ## Copy stuff, symlinks do not work (chroot environment):
-    cp -r $INSTALLER $TFTPROOT
-    append2PXEmenu
-}
+    cp -ru $INSTALLER $TFTPROOT
 
-append2PXEmenu () {
     if [ -d $TFTPROOT/debian-installer/i386 ] ; then
 	## add installer menu
 	cat >> $TFTPROOT/pxelinux.cfg/default <<EOF
@@ -82,43 +125,6 @@ EOF
 }
 
 
-setup_diskless () {
-    export LC_ALL=C
-    fai -vNu diskless dirinstall /opt/live/filesystem.dir/
-
-    TEMPLATE=$TFTPROOT/pxelinux.cfg/diskless.tmpl
-    if [ ! -e $TEMPLATE ]; then
-	KERNEL=`basename $(ls $TFTPROOT/vmlinuz*)`
-	INITRD=`basename $(ls $TFTPROOT/initrd.img*)`
-
-	echo "Creating template with $KERNEL and $INITRD."
-	cat > $TEMPLATE <<EOF
-# template for diskless
-default fai-generated
-
-label fai-generated
-kernel $KERNEL
-append initrd=$INITRD ip=dhcp root=/dev/nfs nfsroot=/opt boot=live
-EOF
-    else
-	echo "The template $TEMPLATE exists already!"
-    fi
-
-    ## Create pxelinux boot configuration for disklessXX.
-    ## The seq range is sed from the corresponding variable
-    ## when fcopy'd:
-    NUM=0
-    for i in `seq DL_RANGE` ; do
-	NUMSTR=`printf "%02d" $NUM`
-	fai-chboot -vc diskless.tmpl diskless$NUMSTR  2>&1 | tee -a /var/log/fai/fai-chboot.log
-	NUM=$(($NUM+1))
-    done
-
-    ## Boot unknown machines as diskless:
-    fai-chboot -vc diskless.tmpl default
-    append2PXEmenu
-}
-
 #########################
 
 ## Setup nfsroot for FAI:
@@ -155,7 +161,7 @@ if [ ! -d $DLROOT ] ; then
 ================================================================================
 To install the chroot for diskless clients execute:
     export LC_ALL=C
-    fai -vNu diskless dirinstall /opt/live/filesystem.dir/
+    fai -vNu diskless dirinstall $DLROOT/filesystem.dir/
 This can be done right now or manually.
 If unanswered, this script will exit after $TIMEOUT seconds.
 
@@ -166,6 +172,7 @@ EOF
 	y)
 	    check_network
 	    setup_diskless
+	    setup_PXEinstaller
 	    ;;
 	*)
 	    exit 0

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list