Improve namespace cleanup to make sure some required directories stick around, and...
[util-vserver.git] / scripts / functions
index f3bb242..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
@@ -1004,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
 {