Point to the FAI wiki for information about how to use it.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 7 Oct 2006 12:13:57 +0000 (12:13 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 7 Oct 2006 12:13:57 +0000 (12:13 +0000)
Make AUTO the default.
Move the prompt to after the trap has been setup.
Run base.__cleanup as the last step of killprocs, so the files needed are still around for the rest of the cleanup.
Use isVserverRunning so the runfile is cleaned up too.
Mount the NFS-root and the target with -o dev, to allow the device nodes.

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2352 94cd875c-1c1d-0410-91d2-eb244daf1a30

scripts/vserver-build.fai

index 94ea3be..b59951c 100644 (file)
@@ -25,6 +25,7 @@ DISTRIBUTION=:
 FAI_VSERVER=
 FAI_NFSROOT=/usr/lib/fai/nfsroot
 FAI_DIR=/usr/local/share/fai
+AUTO=1
 
 use_pkgmgmt=
 while true; do
@@ -32,7 +33,7 @@ while true; do
        -f)             FAI_VSERVER=$2; shift; ;;
        -n)             FAI_NFSROOT=$2; shift; ;;
        -d)             FAI_DIR=$2; shift; ;;
-       -a)             AUTO=1; ;;
+       -a)             AUTO=;;
        --debug)        DEBUG=1; SH_DEBUG=-x; set -x;;
        --)             shift; break ;;
        *)              echo "vserver-build.fai: internal error: unrecognized option '$1'" >&2
@@ -90,8 +91,9 @@ fi
 if ! grep -qw VIRTUAL "$FAI_NFSROOT/usr/sbin/fai"
 then
     panic $"\
-*** Looks like you don't have the patched FAI.
-*** get it from svn://svn.debian.org/svn/fai/people/mugwump/vserver"
+ERROR: Looks like you don't have the patched FAI.
+See http://faiwiki.informatik.uni-koeln.de/index.php/Using_FAI_as_a_vserver_build_method
+for information on where to get it."
 fi
 
 set -e
@@ -100,33 +102,38 @@ set -e
 # state.
 console=dummy
 
-# set up interfaces, so that the vserver can be built with restricted
-# network access.
-generateOptions "$SETUP_CONFDIR"
-enableInterfaces "$SETUP_CONFDIR"
-
-# last chance to abort!
-if [ -z "$AUTO" ]
-then
-    echo -n "Press ENTER to begin, or Ctrl+C to cancel: "
-    read junk
-fi
-
 killprocs() {
-    base.__cleanup
-    S_CONTEXT=$($_CAT "$SETUP_CONFDIR"/run 2>/dev/null)
-    if [ $? -eq 0 -a -d "/proc/virtual/$S_CONTEXT" ]
+    set +e
+    S_CONTEXT=
+    if isVserverRunning "$SETUP_CONFDIR" S_CONTEXT
     then
        $_VKILL -c "$S_CONTEXT" -s 15
        sleep 2
        $_VKILL -c "$S_CONTEXT" -s 9
+       sleep 2
+       isVserverRunning "$SETUP_CONFDIR" && warning $"\
+Vserver '$VSERVER_NAME' still running unexpectedly; please investigate it
+manually."
     fi
-    set -x
-    disableInterfaces "$SETUP_CONFDIR"
+    [ -n "$HAVE_INTERFACES" ] && disableInterfaces "$SETUP_CONFDIR"
+    base.__cleanup
 }
 
 trap killprocs INT EXIT
 
+# last chance to abort!
+if [ -z "$AUTO" ]
+then
+    echo -n "Press ENTER to begin, or Ctrl+C to cancel: "
+    read junk
+fi
+
+# set up interfaces, so that the vserver can be built with restricted
+# network access.
+generateOptions "$SETUP_CONFDIR"
+enableInterfaces "$SETUP_CONFDIR"
+HAVE_INTERFACES=1
+
 rwpaths="/var/lock /var/log /dev /var/run /etc/sysconfig"
 [ -d "$FAI_NFSROOT/etc/network/run" ] && rwpaths="$rwpaths /etc/network/run"
 
@@ -135,10 +142,10 @@ export VDIR ROOTDIR FAI_VSERVER FAI_DIR FAI_NFSROOT FAI_ROOT console
 [ -z "$AUTO" ] && FINAL_SHELL="exec /bin/sh -i"
 
 # set up /mnt with all the mounts required
-$_SECURE_MOUNT -n -o ro --bind "$FAI_NFSROOT" /mnt
+$_SECURE_MOUNT -n -o ro,dev --bind "$FAI_NFSROOT" /mnt
 $_SECURE_MOUNT -n -t tmpfs -o size=64m,mode=1777 vm /mnt/tmp
 $_MKDIR -p /mnt/tmp/target
-$_SECURE_MOUNT -n --bind "$VDIR" /mnt/tmp/target
+$_SECURE_MOUNT -n -o rw,dev --bind "$VDIR" /mnt/tmp/target
 $_MKDIR -p /mnt/tmp/target/proc
 $_SECURE_MOUNT -n -t proc proc /mnt/tmp/target/proc
 for x in $rwpaths