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

Andreas B. Mundt andi at debian.org
Sat Sep 22 11:23:44 UTC 2012


The following commit has been merged in the master branch:
commit 8fcf0249a98870e9d3871b0c668d4efa2fa535fe
Author: Andreas B. Mundt <andi at debian.org>
Date:   Sat Sep 22 13:00:06 2012 +0200

    Rewrite setup script for FAI and diskless machines' chroots.
    
    Cleanup.  Move git initialization for the config space to the
    FAISERVER script.

diff --git a/fai/config/files/etc/rc.local/FAISERVER b/fai/config/files/etc/rc.local/FAISERVER
index 39be75a..6d656e4 100755
--- a/fai/config/files/etc/rc.local/FAISERVER
+++ b/fai/config/files/etc/rc.local/FAISERVER
@@ -3,43 +3,28 @@
 set -e
 
 ## Setup script run at boot time.
-## Moved after successful execution.
 
 ############################
 TIMEOUT=120
-TFTPDIR="/srv/tftp/fai"
+URL="http.debian.net"
 URLIMGi386="http://http.us.debian.org/debian/dists/wheezy/main/installer-i386/current/images/netboot/netboot.tar.gz"
 URLIMGamd64="http://http.us.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/netboot.tar.gz"
 
-cat <<EOF
-================================================================================
-The nfsroot for FAI may be created 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
-inp=${inp:-N}
-case $inp in
-    y)
-	;;
-    *)
-	exit 0
-	;;
-esac
-
+DLROOT="/opt/live"
 . /etc/fai/fai.conf
 . /etc/fai/nfsroot.conf
 
-if [ ! -d "$FAI_CONFIGDIR/class" ] ; then
-    mkdir -p $FAI_CONFIGDIR
-    cp -a /usr/share/doc/fai-doc/examples/simple/* $FAI_CONFIGDIR
-fi
+##########
 
-URL="http.debian.net"
-## Check if package repository is accessible:
-if wget --quiet --output-document=/tmp/fai-setup $URL ; then
+check_network () {
+    ## Check if package repository is accessible:
+    if ! wget --quiet --output-document=/tmp/fai-setup $URL ; then
+	echo "Error accessing '$URL', check network and internet access."
+	exit 1
+    fi
+}
+
+setup_nfsroot () {
     echo "Creating the nfsroot for FAI."
     fai-setup -e -v -l
     ## Create pxelinux boot configuration for workstationXX.
@@ -52,18 +37,23 @@ if wget --quiet --output-document=/tmp/fai-setup $URL ; then
 	NUM=$(($NUM+1))
     done
 
-    ## create default configuration (sysinfo) if not yet in place:
-    fai-chboot -p -S default
+    ## create default configuration (sysinfo):
+    fai-chboot -Svu $FAI_CONFIG_SRC default
+}
 
+setup_PXEinstaller () {
     ## Add Debian PXE Installer:
-    wget --output-document=$TFTPDIR/netboot_i386.tar.gz $URLIMGi386 && \
-	tar xvf $TFTPDIR/netboot_i386.tar.gz -C $TFTPDIR ./debian-installer/
-    wget --output-document=$TFTPDIR/netboot_amd64.tar.gz $URLIMGamd64 && \
-	tar xvf $TFTPDIR/netboot_amd64.tar.gz -C $TFTPDIR ./debian-installer/
-
-    if [ -d $TFTPDIR/debian-installer/i386 ] ; then
+    wget --output-document=$TFTPROOT/netboot_i386.tar.gz $URLIMGi386 && \
+	tar xvf $TFTPROOT/netboot_i386.tar.gz -C $TFTPROOT ./debian-installer/
+    wget --output-document=$TFTPROOT/netboot_amd64.tar.gz $URLIMGamd64 && \
+	tar xvf $TFTPROOT/netboot_amd64.tar.gz -C $TFTPROOT ./debian-installer/
+    append2PXEmenu
+}
+
+append2PXEmenu () {
+    if [ -d $TFTPROOT/debian-installer/i386 ] ; then
 	## add installer menu
-	cat >> $TFTPDIR/pxelinux.cfg/default <<EOF
+	cat >> $TFTPROOT/pxelinux.cfg/default <<EOF
 menu label Debian-LAN/FAI live system
 
 menu title Boot menu
@@ -92,26 +82,78 @@ label Debian Installer amd64
         config debian-installer/amd64/pxelinux.cfg/default
 EOF
     fi
+}
+
+
+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*)`
 
-    ## Use git to track modifications of the config space:
-    cd $FAI_CONFIGDIR
-    HOME="/root"
-    git config --global user.name  root
-    git config --global user.email root@`hostname --fqdn`
-    git config --global color.ui auto
-    git init
-    git add .
-    git commit -m "Initial commit"
-    cd -
-
-    if [ "$0" = "/etc/rc.local" ] ; then
-        ## things are prepared now, keep script for reference:
-	mv -v $0 $0_setup
-	mv -v /etc/rc.local.pre_fcopy $0
+	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
-    ## The following message is activated if diskless machines
-    ## are to be served.  Do not change the following line:
-    exit 0  ##DISKLESS_SERVER##
+
+    ## 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:
+if [ ! -d $NFSROOT ] ; then
+    cat <<EOF
+================================================================================
+The nfsroot for FAI may be created 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
+    inp=${inp:-N}
+    case $inp in
+	y)
+	    check_network
+	    setup_nfsroot
+	    setup_PXEinstaller
+	    ;;
+	*)
+	    exit 0
+	    ;;
+    esac
+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
     cat <<EOF
 ================================================================================
 To install the chroot for diskless clients execute:
@@ -125,14 +167,11 @@ EOF
     inp=${inp:-N}
     case $inp in
 	y)
-	    export LC_ALL=C
-	    fai -vNu diskless dirinstall /opt/live/filesystem.dir/
+	    check_network
+	    setup_diskless
 	    ;;
 	*)
 	    exit 0
 	    ;;
     esac
-else
-    echo "Error accessing '$URL', check network and internet access."
-    exit 0
 fi
diff --git a/fai/config/scripts/DISKLESS_CLIENT/20-server b/fai/config/scripts/DISKLESS_CLIENT/20-server
deleted file mode 100755
index cfc58bb..0000000
--- a/fai/config/scripts/DISKLESS_CLIENT/20-server
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-#
-# modifications needed on the server to boot the diskless client
-#
-
-set -e
-
-TFTPDIR="/srv/tftp/fai"
-
-if [ $FAI_ACTION == "dirinstall" ] ; then
-    TEMPLATE=$TFTPDIR/pxelinux.cfg/diskless.tmpl
-
-    if [ ! -e $TEMPLATE ]; then
-	KERNEL=`basename $(ls /srv/tftp/fai/vmlinuz*)`
-	INITRD=`basename $(ls /srv/tftp/fai/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
-    fai-chboot -vc diskless default
-
-    if [ -d $TFTPDIR/debian-installer/i386 ] ; then
-	## add installer menu
-	cat >> $TFTPDIR/pxelinux.cfg/default <<EOF
-menu label Debian-LAN/FAI live system
-
-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
-ontimeout fai-generated
-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
-fi
diff --git a/fai/config/scripts/FAISERVER/10-config b/fai/config/scripts/FAISERVER/10-config
index a849fa4..1bcaafe 100755
--- a/fai/config/scripts/FAISERVER/10-config
+++ b/fai/config/scripts/FAISERVER/10-config
@@ -4,12 +4,11 @@ set -e
 
 fcopy -r /etc/fai
 
-if [ $FAI_ACTION == "install" ]; then
-    ## fetch template and insert 'number' of workstations:
-    fcopy  /etc/rc.local
-    sed -i "s/WS_RANGE/${WS_RANGE}/g" $target/etc/rc.local
-
-    if ifclass DISKLESS_SERVER ; then
-	sed -i "s%\(^.*\#\#DISKLESS_SERVER\#\#\)%\#\1%"  $target/etc/rc.local
-    fi
+## fetch template and insert 'number' of workstations:
+fcopy  /etc/rc.local
+sed -i "s/WS_RANGE/${WS_RANGE}/g" $target/etc/rc.local
+sed -i "s/DL_RANGE/${DL_RANGE}/g" $target/etc/rc.local
+
+if ifclass DISKLESS_SERVER ; then
+    sed -i "s%\(^.*\#\#DISKLESS_SERVER\#\#\)%\#\1%"  $target/etc/rc.local
 fi
diff --git a/fai/config/scripts/FAISERVER/20-configspace b/fai/config/scripts/FAISERVER/20-configspace
index a3c2b6c..4870b5f 100755
--- a/fai/config/scripts/FAISERVER/20-configspace
+++ b/fai/config/scripts/FAISERVER/20-configspace
@@ -2,14 +2,26 @@
 
 set -e
 
+CONFDIR="/srv/fai/config"
+
 if [ $FAI_ACTION == "install" ] ; then
     ## Copy the config space to the faiserver:
     echo -n "Cleaning config space ... "
-    rm -rf $target/srv/fai/config
+    rm -rf $target/$CONFDIR
     echo "done."
 
-    cp -a /var/lib/fai/config $target/srv/fai/
-    chmod 770 $target/srv/fai/config/
-    chown root:adm $target/srv/fai/config/
+    mkdir -p $target/$CONFDIR
+    cp -a /var/lib/fai/config/* $target/$CONFDIR
+    chmod 770 $target/$CONFDIR
+    chown root:adm $target/$CONFDIR
     echo "New config space copied to faiserver."
+
+    ## Use git to track modifications of the config space:
+    export HOME="/root"
+    $ROOTCMD git config --global user.name  root
+    $ROOTCMD git config --global user.email root@$HOSTNAME
+    $ROOTCMD git config --global color.ui auto
+    $ROOTCMD git init $CONFDIR
+    $ROOTCMD git --git-dir=$CONFDIR/.git --work-tree=$CONFDIR add .
+    $ROOTCMD git --git-dir=$CONFDIR/.git commit -m "Initial commit"
 fi

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list