_VS_NEWLINE='
'
declare -r _VS_NEWLINE=${_VS_NEWLINE:0-1}
-declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running
function findObject
{
export INIT_CWD
}
-function _getVserverDir
+function _setVserverDir
{
local vserver="$1"
case "$vserver" in
esac
}
+function _setVserverName
+{
+ VSERVER_NAME=$(basename "$VSERVER_DIR")
+}
+
function _pkgMountBindDir()
{
test "$1" != "$2" || return 0
$_VSERVER_INFO - FEATURE namespace || return 1
cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1
+ isAvoidNamespace "$1" && return 1
test -e "$cfgdir"/namespace-cleanup && return 0
test -e "$cfgdir"/nonamespace-cleanup -o \
-e "$__CONFDIR"/.defaults/nonamespace-cleanup && return 1
{
local _ga_i
declare -a _ga_tmp=()
+ local _ga_IFS="$IFS"
+ IFS=,
+ local -a _ga_marks=( $3 )
+ IFS="$_ga_IFS"
for _ga_i in $__CONFDIR/*; do
isRegularFile "$_ga_i" -d || continue
(STOPPED) ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
(RUNNING) $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
(ALL) ;;
+ (MARK) local _ga_j
+ local _ga_mark
+ local _ga_f=false
+ local _ga_invert=false
+ for _ga_j in "${_ga_marks[@]}"; do
+ _ga_mark="$(echo "$_ga_j" | $_SED 's/^[!~]//')"
+ test "$_ga_j" = "$_ga_mark" || _ga_invert=true
+ test -s "$_ga_markfile" && $_GREP -qx "$_ga_mark" "$_ga_markfile" && \
+ _ga_f=true || :
+ done
+ test $_ga_f = $_ga_invert && \
+ _ga_doadd=
+ ;;
(*) panic $"Unknown vserver tagging '$2'";;
esac
eval $1='( "${_ga_tmp[@]}" )'
}
+declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running,mark:
## Usage: getAllVserversByArg <var> <arg>
function getAllVserversByArg
{
local _gav_mark=
-
- case $2 in
- (--all) _gav_mark=ALL;;
- (--marked) _gav_mark=MARKED;;
- (--unmarked) _gav_mark=UNMARKED;;
- (--stopped) _gav_mark=STOPPED;;
- (--running) _gav_mark=RUNNING;;
- (*) return 1;;
- esac
+ local _gav_v="$1"
+ local _gav_first=1
+ local _gav_res=()
+ shift
+
+ while test "$#" -ge 1; do
+ local _gav_extra=
+ local _gav_tmp=()
+
+ case "$1" in
+ (--all) _gav_mark=ALL;;
+ (--marked) _gav_mark=MARKED;;
+ (--unmarked) _gav_mark=UNMARKED;;
+ (--stopped) _gav_mark=STOPPED;;
+ (--running) _gav_mark=RUNNING;;
+ (--mark*) _gav_mark=MARK
+ _gav_extra=${_gav_i##*=}
+ test -n "$_gav_extra" -a "$_gav_extra" != "--mark" || \
+ _gav_extra="$2"
+ shift
+ ;;
+ (--) break;;
+ (*) set -- "$_gav_v" "$@"
+ return 1;;
+ esac
- getAllVservers "$1" "$_gav_mark"
+ getAllVservers _gav_tmp "$_gav_mark" $_gav_extra
+ if test -n "$_gav_first"; then
+ _gav_res=( "${_gav_tmp[@]}" )
+ else
+ local _gav_i=0
+ local _gav_n="${#_gav_res[@]}"
+ while test $_gav_i -lt $_gav_n; do
+ local _gav_found=0
+ for _gav_j in "${_gav_tmp[@]}"; do
+ if test "$_gav_j" = "${_gav_res[$_gav_i]}"; then
+ _gav_found=1
+ break
+ fi
+ done
+ if test "$_gav_found" = 0; then
+ unset _gav_res[$_gav_i]
+ fi
+ let ++_gav_i
+ done
+ _gav_res=( "${_gav_res[@]}" )
+ fi
+ shift
+ _gav_first=
+ done
+ eval $_gav_v='( "${_gav_res[@]}" )'
}
## Usage: _getProcNumberCount <ctx> <var>
read _gvs_ctx <"$1"/run
eval "$2"=\$_gvs_ctx
- test -n "$3" || return 0
- local _gvs_tmp
- _getProcNumberCount "$_gvs_ctx" _gvs_tmp
- eval "$3"=\$_gvs_tmp
+ if test "$1" = "$($_VUNAME -g --xid "$_gvs_ctx" context)"; then
+ test -n "$3" || return 0
+ local _gvs_tmp
+ _getProcNumberCount "$_gvs_ctx" _gvs_tmp
+ eval "$3"=\$_gvs_tmp
+ else
+ test -n "$3" || return 1
+ eval "$3"=0
+ _gvs_tmp=0
+ fi
if test "$_gvs_tmp" = 0; then
local runfile=$($_READLINK "$1/run")
"$__CONFDIR/.defaults/apps/init/tty" \
$2 /dev/null
- exec <$ttyname
- exec &>$ttyname
+ if test -f "$ttyname"; then
+ exec </dev/null
+ else
+ exec <$ttyname
+ fi
+ exec >>$ttyname 2>&1
}
## Usage: killContext <XID> [<SIG>]
local xid
xid=$($_VSERVER_INFO "$1" CONTEXT false) && test -n "$xid" || {
- warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
+ warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'
+
+This usually means that you're using an init-less init-style, but the
+guest isn't configured to start any service. Try enabling a service,
+changing the init-style, or making the contexts persistent."
return 1
}
test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC"
}
+function vshelper.isStopSync
+{
+ test -p "$VSHELPER_STOP_SYNC" || return 1
+ return 0
+}
+
function _rpmFake.getCapFlags
{
local ctx=$1