bcapabilities and ccapabilities won't be changing names any time soon, remove experim...
[util-vserver.git] / scripts / functions
index 69e57f0..51318e7 100644 (file)
@@ -268,6 +268,16 @@ function unlock
     _VS_LOCKS="$@"
 }
 
+function _getVserverDir
+{
+    local vserver="$1"
+    case "$vserver" in
+       ./*) VSERVER_DIR=`pwd`/$vserver     ;;
+       /*)  VSERVER_DIR=$vserver           ;;
+       *)   VSERVER_DIR=$__CONFDIR/$vserver;;
+    esac
+}
+
 function _pkgMountBindDir()
 {
     test "$1" != "$2" || return 0
@@ -480,6 +490,18 @@ function isAvoidNamespace
          -e "$cfgdir"/nonamespace
 }
 
+function isNamespaceCleanup
+{
+    local cfgdir
+
+    $_VSERVER_INFO - FEATURE namespace   || return 1
+    cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1
+    test -e "$cfgdir"/nonamespace-cleanup && return 1
+    test -e "$__CONFDIR"/.defaults/namespace-cleanup -o \
+         -e "$cfgdir"/namespace-cleanup && return 0
+    return 1
+}
+
 ## Usage: getAllVservers <var> [<KIND>*]
 function getAllVservers
 {
@@ -992,6 +1014,30 @@ function vshelper.getSyncTimeout
     eval $2=\$_vgst_tmp
 }
 
+function vshelper.initStopSync
+{
+       local _iss_sync_dir=$($_MKTEMPDIR vshelper-stop-sync.XXXXXX) || {
+               warning $"Failed to generate directory for vshelper sync"
+               exit 1
+       }
+       $_MKFIFO -m700 "$_iss_sync_dir/pipe"
+
+       eval "$1"=\$_iss_sync_dir
+       VSHELPER_STOP_SYNC="$_iss_sync_dir/pipe"
+       export VSHELPER_STOP_SYNC
+}
+
+function vshelper.waitForStopSync
+{
+       local sync_dir=$1
+       cat "$sync_dir/pipe" &> /dev/null
+       rm -fr "$sync_dir"
+}
+
+function vshelper.doStopSync
+{
+       test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC"
+}
 
 function _rpmFake.getCapFlags
 {