Clarify that specifying dev will add/remove the IP address.
[util-vserver.git] / scripts / vserver.functions
index ce50c3b..546cc6a 100644 (file)
@@ -43,6 +43,8 @@ declare -a OPTS_VCONTEXT_ENTER=()
 declare -a OPTS_VATTRIBUTE=( --flag fakeinit )
 declare -a OPTS_VSCHED=()
 declare -a OPTS_ENV=()
+declare -a OPTS_VTAG_CREATE=()
+declare -a OPTS_VTAG_ENTER=()
 
 declare -a STOPCMD_PREPARE=()
 
@@ -278,6 +280,11 @@ function _generateInitOptions
                INITCMD_STOP=(  "$i" "$RUNLEVEL_STOP"  )
            done
            INITCMD_PREPARE=( $_FAKE_RUNLEVEL "$RUNLEVEL_START" /var/run/utmp )
+           OPTS_ENV=( "${OPTS_ENV[@]}" PREVLEVEL=N RUNLEVEL="$RUNLEVEL_START" )
+           if test -n "$OPTION_DEBUG_SYSV"; then
+               INITCMD_START=( /bin/bash -x "${INITCMD_START[@]}" )
+               INITCMD_STOP=( /bin/bash -x "${INITCMD_STOP[@]}" )
+           fi
            ;;
            
        (xplain)
@@ -594,6 +601,17 @@ function _generateInterfaceOptions
     _HAVE_INTERFACE_OPTIONS=1
 }
 
+function _generateTagOptions
+{
+    local vdir="$1"
+    local tag
+
+    getFileValue tag "$vdir/tag" "$vdir/context" || return 0
+
+    OPTS_VTAG_CREATE=( --tag "$tag" )
+    OPTS_VTAG_ENTER=( --tag "$tag" )
+}
+
 function enableInterfaces
 {
     local i=0
@@ -690,7 +708,7 @@ function prepareStop
     pushd "$1/vdir" >/dev/null
     case "$INITSTYLE" in
        (sysv)
-           export PREVLEVEL=$RUNLEVEL_START # required by Debian's initscripts
+           export PREVLEVEL=$RUNLEVEL_START RUNLEVEL=$RUNLEVEL_STOP # required by Debian's initscripts
            ;;
     esac
     "${STOPCMD_PREPARE[@]}"
@@ -707,6 +725,7 @@ function generateOptions
     _generateChcontextOptions   "$1"
     _generateScheduleOptions    "$1"
     _generatePersonalityOptions "$1"
+    _generateTagOptions         "$1"
 
     if test -n "$_IS_FAKEINIT"; then
        CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
@@ -1061,6 +1080,15 @@ WARNING: There is no cachedirectory configured for this vserver;
 /proc/uptime can not be accessed. Usually, this is caused by
 procfs-security. Please read the FAQ for more details
 http://linux-vserver.org/Proc-Security"
+
+    test -e "$cfgdir"/context || {
+       TYPE=$( $_VSERVER_INFO 49152 XIDTYPE )
+       test "$TYPE" != "static" || panic $"\
+The kernel does not have dynamic contexts enabled. Please configure
+a static one by executing
+
+  echo [number between 2 and 49151] > $cfgdir/context"
+    }
 }