getPhysicalDir doesn't work if it doesn't already exist.
[util-vserver.git] / sysv / util-vserver
index 047ef45..d56dadc 100755 (executable)
@@ -14,6 +14,8 @@ test -e "$UTIL_VSERVER_VARS" || {
 
 LOCKFILE=util-vserver
 . "$_LIB_VSERVER_INIT_FUNCTIONS"
+. "$_LIB_FUNCTIONS"
+. "$__PKGLIBDIR/vserver.functions"
 
 
 function set_helper()
@@ -45,12 +47,23 @@ function kill_contexts()
     test $alive = 0
 }
 
+function create_dirs()
+{
+    $_MKDIR -p "$__RUNDIR" && $_MKDIR -p "$__VSHELPERSTATEDIR" && $_MKDIR -p `$_READLINK "$__PKGSTATEREVDIR"`
+}
+
 function start()
 {
+    _beginResult $"Creating required directories"
+    create_dirs
+    _endResult $?
     _beginResult $"Setting path to vshelper"
     set_helper
     _endResult $?
     local retval=$?
+    _beginResult $"Loading default device map"
+    handleDeviceMap --set 0 "$__CONFDIR/.defaults/apps/vdevmap"
+    _endResult $?
     test "$retval" -ne 0 || touch "$lockfile"
     return $retval
 }
@@ -61,11 +74,12 @@ function stop()
     _beginResult $"Stopping all running guests"
     $_START_VSERVERS -j 1 --all --stop
     _endResult $?
-    local retval=$?
     _beginResult $"Killing all running contexts"
     kill_contexts
     _endResult $?
+    local retval=$?
     $_RM -f "$lockfile"
+    return $retval
 }
 
 function restart()
@@ -82,10 +96,10 @@ case "$1" in
        ;;
     status)
        test -f $lockfile && {
-           echo $"/proc entries were fixed"
+           echo $"Path to vshelper has been set"
            exit 0
        }
-       echo $"/proc entries are not fixed"
+       echo $"Path to vshelper has not been set"
        exit 1
        ;;
     *)