Don't set _IS_FAKEINIT on rescue, let the caller decide with --rescue-init.
[util-vserver.git] / scripts / vserver.functions
index cd0cccd..592d3f1 100644 (file)
@@ -247,7 +247,8 @@ function _generateInitOptions
     CHCONTEXT_INIT_OPTS=()
 
 
-    getFileValue INITSTYLE      "$cfgdir"/style
+    test -n "$INITSTYLE" || \
+      getFileValue INITSTYLE    "$cfgdir"/style
     getFileValue RUNLEVEL_START "$cfgdir"/runlevel
     getFileValue RUNLEVEL_START "$cfgdir"/runlevel.start
     getFileValue RUNLEVEL_STOP  "$cfgdir"/runlevel.stop
@@ -262,8 +263,6 @@ function _generateInitOptions
        (xrescue)
            INITCMD_START=( "${INITCMD_RESCUE[@]}" )
            INITCMD_STOP=( /sbin/killall5 )
-           _IS_FAKEINIT=1
-           _NEED_VSHELPER_SYNC=
            ;;
            
        (xsysv)
@@ -299,7 +298,27 @@ function _generateInitOptions
            ;;
 
        (xgentoo)
-           panic "init-style '$INITSTYLE' is no longer supported; please use plain instead; aborting";;
+           test -n "$RUNLEVEL_START" || RUNLEVEL_START="default"
+
+           INITCMD_START=( /lib/rcscripts/sh/init-vserver.sh "$RUNLEVEL_START" )
+           INITCMD_STOP=( /sbin/rc shutdown )
+           INITCMD_PREPARE=( $_FAKE_RUNLEVEL 3 /var/run/utmp )
+
+           pushd "$vdir"/vdir &>/dev/null
+           basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
+           popd &>/dev/null
+
+           basemaj=${basever/.*}
+           basemin=${basever#*.}
+           basemin=${basemin/.*}
+
+           test "$basemaj" -lt 1 -o "$basemin" -lt 13 && \
+           panic "\
+Using init-style 'gentoo' requires >=baselayout-1.13 inside the vserver!
+
+Your vserver ($(basename "$vdir")) seems to have baselayout-$basever,
+please use 'plain' init-style instead!"
+           ;;
 
        (x) ;;
        (*) panic "Unknown init-style '$INITSTYLE'; aborting";;
@@ -390,6 +409,11 @@ function _generateChcontextOptions
 function _generateScheduleOptions
 {
     local vdir=$1
+    if test -d "$vdir"/sched; then
+      OPTS_VSCHED=( --dir "$vdir"/sched --missingok )
+      return 0
+    fi
+
     local f="$vdir"/schedule
     test -e "$f" || return 0