3 # Copyright (C) 2003,2004,2005,2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 declare -r _VS_NEWLINE=${_VS_NEWLINE:0-1}
24 declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running
35 test -n "$_fo_i" || continue
36 test ! $_fo_mod "$_fo_i" || { _fo_file=$_fo_i; break; }
39 test -z "$_fo_i" -o -n "$_fo_file" || {
40 echo "Can not find file for '$_fo_var'; aborting"
44 eval "$_fo_var=\"$_fo_file\""
60 test ! -s "$dst" || return 0
66 test -n "$tmp" -a -s "$tmp" || return 0
67 $_CP -af "$tmp" "$dst"
70 ## Usage: isRegularFile <filename> [<mod>]
71 function isRegularFile
73 test ${2:--f} "$1" || return 1
76 (*.rpmsave|*.rpmnew|*.rpmorig|*.cfsaved*|*.~*~) return 1;;
82 function getPhysicalDir
84 ( set -P && cd "$1" && pwd )
87 ## Usage:: isDirectoryEmpty <dir> [<ignore-lost+found>]
88 function isDirectoryEmpty
92 shopt -s nullglob || *
95 test -z "$2" -o "$2" = 0 || ignore_lostfound=
100 test "$ignore_lostfound" || exit 1
102 (*) echo "$i"; exit 1
110 ## Usage: logging <message>
113 if test -n "$_VS_LOGFILE"; then
114 echo "$@" >>"$_VS_LOGFILE"
120 ## Usage: warning <message>
123 if test -n "$_VS_ERRFILE"; then
124 echo "$@" >>"$_VS_ERRFILE"
130 ## Usage: panic <message>
133 if test -n "$_VS_ERRFILE"; then
134 echo "$@" >>"$_VS_ERRFILE"
142 ## Usage: execute <message>
145 test -z "${DEBUG_EXEC:-}" || echo "$@"
146 test "${DEBUG_EXEC:-}" = noexec || exec "$@"
151 ## Usage: spawn <message>
154 test -z "${DEBUG_EXEC:-}" || echo "$@"
155 test "${DEBUG_EXEC:-}" = noexec || "$@"
158 ## Usage: isNumber <arg>
162 let tmp=$1+0 2>/dev/null || test -z "${1//0/}" -a -n "$1" || return 1
166 ## Usage: hasSubstring <haystack> <needle>+
167 function hasSubstring
175 test x"${pat/*$i*/$i}" = x"$i" || continue
182 ## Usage: colorize <style> <command>
192 findFile cfile "$__CONFDIR"/.defaults/styles/"$style" ''
193 if test -n "$cfile"; then
197 (bold) echo -ne "\e[1m";;
198 (emph) echo -ne "\e[34m";;
199 (info) echo -ne "\e[0;34m";;
200 (warn*) echo -ne "\e[1;31m";;
201 (error) echo -ne "\e[1;33;41m";;
213 if test -n "$_VS_ERRFILE"; then
214 echo "$@" >>"$_VS_ERRFILE"
216 colorize error echo -n "$@" >&2
225 colorize warning warning "$@"
230 colorize info echo "$@"
234 ## Usage: xtermTitle <title>
238 echo -ne "\e]0;$@\007"
242 ## Usage: lock <lockfile> [<timeout>]
245 local tmp=$($_MKTEMP vserver-lock.XXXXXX)
249 $_LOCKFILE "$1" $tmp $2 &
250 $_GREP -q true $tmp 2>/dev/null || return 1
252 _VS_LOCKS="$! $_VS_LOCKS"
255 ## Usage: unlock [<num>]
262 while test "$#" -gt 0; do
263 kill -HUP "$1" >/dev/null || :
265 test "$num" != 1 || break
266 test -z "$num" || let --num
271 function _getVserverDir
275 ./*) VSERVER_DIR=`pwd`/$vserver ;;
276 /*) VSERVER_DIR=$vserver ;;
277 *) VSERVER_DIR=$__CONFDIR/$vserver;;
281 function _pkgMountBindDir()
283 test "$1" != "$2" || return 0
285 $_MOUNT -n --bind "$1" "$2"
288 function _pkgSetVarsBase
292 if test -d "$vserver/vdir"; then
294 VDIR=$(getPhysicalDir "$vserver/vdir")
296 PKGDIR=$BASEDIR/apps/pkgmgmt
297 test -d "$PKGDIR" || {
298 echo "Can not find configuration-directory for package-managment tools"
301 findDir EXECDIR $PKGDIR/execdir /
303 VDIR=$(getPhysicalDir "$vserver")
308 BASEDIR=$__CONFDIR/$vserver
309 test -d "$BASEDIR" || {
310 echo "Can not find configuration-directory"
315 test -d "$VDIR" || VDIR=$__DEFAULT_VSERVERDIR/$vserver
316 VDIR=$(getPhysicalDir "$VDIR")
318 PKGDIR=$BASEDIR/apps/pkgmgmt
319 test -d "$PKGDIR" || {
320 echo "Can not find configuration-directory for package-managment tools"
324 findDir EXECDIR $PKGDIR/execdir /
329 if test -z "$WORKAROUND_106057"; then
332 _rpmdb_mntpoint=/.rpmdb
336 function _pkgSetVarsRPM
338 if test -n "$PKGDIR"; then
339 findDir RPMETCDIR $PKGDIR/rpmetc $PKGDIR/base/rpm/etc /etc/rpm
340 findDir RPMSTATEDIR $PKGDIR/rpmstate $PKGDIR/base/rpm/state
342 findDir RPMLIBDIR $PKGDIR/rpmlib /
345 findDir RPMETCDIR "$VDIR"/etc/rpm /etc/rpm
346 findDir RPMSTATEDIR "$VDIR"/var/lib/rpm
350 RPMSTATEDIR=$(getPhysicalDir "$RPMSTATEDIR")
351 RPMETCDIR=$(getPhysicalDir "$RPMETCDIR")
354 function _pkgSetVarsApt
356 if test -n "$PKGDIR"; then
357 findDir APTETCDIR $PKGDIR/aptetc $PKGDIR/base/apt/etc /etc/apt
358 findDir APTSTATEDIR $PKGDIR/aptstate $PKGDIR/base/apt/state
359 findDir APTCACHEDIR $PKGDIR/aptcache $PKGDIR/base/apt/cache
360 findDir APTARCHIVDIR $PKGDIR/aptarchives $PKGDIR/base/apt/archives /var/cache/apt/archives
362 findDir APTETCDIR "$VDIR"/etc/apt /etc/apt
363 findDir APTSTATEDIR "$VDIR"/var/state/apt
364 findDir APTCACHEDIR "$VDIR"/var/cache/apt
365 findDir APTARCHIVDIR "$VDIR"/var/cache/apt/archives /var/cache/apt/archives
368 findFile APT_CONFIG "$APTETCDIR"/apt.conf ""
369 test -z "$APT_CONFIG" || export APT_CONFIG
372 function _pkgSetVarsYum
374 if test -n "$PKGDIR"; then
375 findDir YUMETCDIR $PKGDIR/yumetc $PKGDIR/base/yum/etc /etc
376 findDir YUMCACHEDIR $PKGDIR/yumcache $PKGDIR/base/yum/cache
378 findDir YUMETCDIR "$VDIR"/etc /etc
379 findDir YUMCACHEDIR "$VDIR"/var/cache/yum
384 function _pkgMountBase
389 function _pkgMountApt
394 function _pkgMountYum
399 function _pkgMountRPM
401 _pkgMountBindDir "$RPMETCDIR" /etc/rpm
402 test "$RPMLIBDIR" = "/" || _pkgMountBindDir "$RPMLIBDIR" /usr/lib/rpm
404 pushd "$VDIR" >/dev/null
406 $_SECURE_MOUNT --chroot -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
407 test -z "$WORKAROUND_106057" || mount -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
409 test -e "$VDIR"/proc/self/status || \
410 $_SECURE_MOUNT --chroot -n -t proc none /proc
415 function _pkgSetEnvBase
417 test "$EXECDIR" = "/" || {
419 LD_LIBRARY_PATH=$EXECDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
422 export PATH LD_LIBRARY_PATH
425 function _pkgSetEnvApt
430 function _pkgSetEnvYum
435 function _pkgSetEnvRPM
438 RPM_FAKE_NAMESPACE_MOUNTS=$_rpmdb_mntpoint
439 RPM_BINARY=$_VRPM_PRELOAD
441 export CUR_VSERVER RPM_FAKE_NAMESPACE_MOUNTS RPM_BINARY
453 rpm) _pkgSetVarsRPM;;
454 apt) _pkgSetVarsApt;;
455 yum) _pkgSetVarsYum;;
456 *) echo "Unknown packaging flavor" >&2; exit 1;;
479 _PKG_VSERVER=$vserver
482 function isAvoidNamespace
486 $_VSERVER_INFO - FEATURE namespace || return 0
487 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 0
488 test ! -e "$cfgdir"/namespace || return 1
489 test -e "$__CONFDIR"/.defaults/nonamespace -o \
490 -e "$cfgdir"/nonamespace
493 function isNamespaceCleanup
497 $_VSERVER_INFO - FEATURE namespace || return 1
498 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1
499 test -e "$cfgdir"/nonamespace-cleanup && return 1
500 test -e "$__CONFDIR"/.defaults/namespace-cleanup -o \
501 -e "$cfgdir"/namespace-cleanup && return 0
505 ## Usage: getAllVservers <var> [<KIND>*]
506 function getAllVservers
509 declare -a _ga_tmp=()
511 for _ga_i in $__CONFDIR/*; do
512 isRegularFile "$_ga_i" -d || continue
514 test ! -e "$_ga_i"/disabled || continue
515 test -d "$_ga_i"/vdir || continue
518 local _ga_markfile=$_ga_i/apps/init/mark
521 (MARKED) test -s "$_ga_markfile" || _ga_doadd=;;
522 (UNMARKED) test ! -s "$_ga_markfile" || _ga_doadd=;;
523 (STOPPED) ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
524 (RUNNING) $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
526 (*) panic $"Unknown vserver tagging '$2'";;
529 test -z "$_ga_doadd" || _ga_tmp=( "${_ga_tmp[@]}" "${_ga_i##$__CONFDIR/}")
532 eval $1='( "${_ga_tmp[@]}" )'
535 ## Usage: getAllVserversByArg <var> <arg>
536 function getAllVserversByArg
541 (--all) _gav_mark=ALL;;
542 (--marked) _gav_mark=MARKED;;
543 (--unmarked) _gav_mark=UNMARKED;;
544 (--stopped) _gav_mark=STOPPED;;
545 (--running) _gav_mark=RUNNING;;
549 getAllVservers "$1" "$_gav_mark"
552 ## Usage: _getProcNumberCount <ctx> <var>
553 function _getProcNumberCount
556 local _gp_procnr_cnt=0
558 # Use /proc/virtual from kernel 2.6 when possible
559 if test -d "/proc/virtual"; then
560 set -- $($_GREP '^PROC:' "/proc/virtual/$1/limit" 2>/dev/null)
563 _gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l )
566 let _gp_procnr_cnt=_gp_procnr_cnt+0
567 eval $_gp_var=\$_gp_procnr_cnt
570 ## Usage: getVserverCtx <vdir> <result-varname> [<procnumber-varname> [<do-cleanup>]]
571 ## Returns: 0 iff vserver is running
572 function getVserverStatus
574 test -r "$1"/run || return 1
577 read _gvs_ctx <"$1"/run
580 test -n "$3" || return 0
582 _getProcNumberCount "$_gvs_ctx" _gvs_tmp
585 if test "$_gvs_tmp" = 0; then
586 local runfile=$($_READLINK "$1/run")
587 test -z "$4" || $_RM -f "$runfile"
594 ## Usage: isCtxRunning <ctx>
595 function isCtxRunning
598 _getProcNumberCount "$1" _tmp
602 ## Usage: isVserverRunning <vdir> [<ctx-varname>]
603 function isVserverRunning
605 local _ivr_ctx _ivr_procnum
607 getVserverStatus "$1" _ivr_ctx _ivr_procnum 1 || return 1
608 test "$_ivr_procnum" != 0 || return 1
609 test -z "$2" || eval "$2"=\$_ivr_ctx
613 ## Called as 'getFileValue <varname> <filename>+'
614 function getFileValue
620 findFile _gfv_file "$@" ''
621 test -n "$_gfv_file" -a -r "$_gfv_file" || return 0
622 eval read "$_gfv_var" <"$_gfv_file"
625 ## Called as 'getFileArray <varname> <filename>'
626 function getFileArray
628 test -r "$2" || return 1
630 local IFS=$_VS_NEWLINE
631 eval "$1"='( $(< "$2") )'
634 function checkComponents
645 (core) test -x "$_CHBIND" || failed=1;;
646 (build) test -x "$_VSERVER_BUILD" || failed=1;;
647 (sysv) test -x "$__INITRDDIR/vserver" || failed=1;;
648 (devel) test -d "$__INCLUDEDIR/vserver.h" || failed=1;;
649 (*) echo "Unknown component '$i'" >&2
654 test -z "$failed" || {
663 ## Usage: isKernelAPI <ver> [<cmp-modifier>]
667 api=$($_VSERVER_INFO - APIVER) || api=0
668 test $[ $api ] -${2:-ge} $[ $1 ]
671 ## Usage: callInNamespace <vserver> <command> <args>*
672 function callInNamespace
676 isAvoidNamespace "$1" || \
677 ctx=$( $_VSERVER_INFO "$1" CONTEXT f ) || ctx=
680 if test -n "$ctx"; then
681 $_VNAMESPACE --enter "$ctx" -- "$@"
687 ## Usage: setDefaultTTY <vdir> [<fallback-tty>]
688 function setDefaultTTY
692 cfgdir=$($_VSERVER_INFO "$1" APPDIR init) || cfgdir=
693 findObject -e ttyname \
694 ${cfgdir:+"$cfgdir"/tty} \
695 "$__CONFDIR/.defaults/apps/init/tty" \
702 ## Usage: killContext <XID> [<SIG>]
707 #$_VKILL -s STOP --xid "$1" 1 &>/dev/null || :
708 $_VKILL -s "$sig" --xid "$1" 1 &>/dev/null || :
709 $_VKILL -s "$sig" --xid "$1" &>/dev/null || :
710 #$_VKILL -s "$sig" --xid "$1" 1 &>/dev/null || :
711 #$_VKILL -s CONT --xid "$1" 1 &>/dev/null || :
714 ## Usage: pkgmgmt.guessStyle <vserver> <resultvar>
715 function pkgmgmt.guessStyle()
718 _pgs_vdir=$($_VSERVER_INFO "$1" VDIR) || {
719 echo $"Can not determine vserver-root" >&2
722 local _pgs_cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
724 if test -n "$_pgs_cfgdir" -a -e "$_pgs_cfgdir"/style; then
725 read style <"$_pgs_cfgdir"/style
726 elif test -e "$_pgs_vdir"/etc/redhat-release -o -e "$_pgs_vdir"/etc/fedora-release; then
728 elif test -e "$_pgs_vdir"/etc/mandrake-release; then
730 elif test -e "$_pgs_vdir"/etc/debian_version; then
732 elif test -e "$_pgs_vdir"/etc/SuSE-release; then
735 echo $"Can not determine packagemanagement style" >&2
743 ## Usage: pkgmgmt.isInternal <vserver>
744 ## returns true iff <vserver> is configured for internal packagemanagement
745 ## A typical application is
747 ## | pkgmgmt.isInternal "$vserver" || is_external=1
748 function pkgmgmt.isInternal
750 local cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
752 test -z "$cfgdir" -o ! -d "$cfgdir" -o -e "$cfgdir"/internal
755 ## Usage: pkgmgmt.isAptAvailable <cfgdir> <vdir> [<is-internal>]
756 function pkgmgmt.isAptAvailable
760 local is_internal="$3"
763 if test -n "$is_internal"; then
765 test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
768 for i in /bin /usr/bin /usr/local/bin; do
769 test ! -x "$vdir$i"/apt-get || { have_apt=1; break; }
773 test -n "$have_apt" && return 0 || return 1
776 ## Usage: pkgmgmt.isYumAvailable <cfgdir> <vdir> [<is-internal>]
777 function pkgmgmt.isYumAvailable
781 local is_internal="$3"
784 if test -n "$is_internal"; then
786 test -d "$cfgdir"/base/yum -o -d "$cfgdir"/yumetc || have_yum=
789 for i in /bin /usr/bin /usr/local/bin; do
790 test ! -x "$vdir$i"/yum || { have_yum=1; break; }
794 test -n "$have_yum" && return 0 || return 1
798 function vshelper.doSanityCheck
800 local vshelper this_xid i
801 declare -a warnings=()
802 local solution_disable=
803 local solution_sysctl=
805 vshelper.isEnabled && vshelper.isEnabled warning || return 0
807 this_xid=$($_VSERVER_INFO - XID) ||
808 panic $"Failed to determine current context; aborting..."
810 ## Do nothing in other xid's; the helper will be executed in xid 0 only
811 test "$this_xid" = 0 || return 0
813 local proc_file=/proc/sys/kernel/vshelper
815 if ! test -r "$proc_file"; then
817 warnings=( "${warnings[@]}"
818 $"File '$proc_file' does not exist but is required for vshelper setup" )
821 vshelper=$(cat "$proc_file")
823 $_CMP -s "$vshelper" "$_VSHELPER" || {
824 warnings=( "${warnings[@]}"
825 $"The configured vshelper '$vshelper' does not match the 'vshelper'
826 script of the util-vserver package"
833 test -d "$__VSHELPERSTATEDIR" || {
834 warnings=( "${warnings[@]}"
836 The vshelper state-directory '$__VSHELPERSTATEDIR' does not exist; since
837 it is created by 'make install', this indicates a serious problem with
838 your util-vserver installation" )
842 test "${#warnings[@]}" -eq 0 || {
844 The following problem(s) were encountered while verifying vshelper
847 for i in "${warnings[@]}"; do
853 To fix this, you can:"
855 test -z "$solution_disable" || warning $"\
856 * disable vshelper entirely by executing
857 | touch \"$__CONFDIR/.defaults/apps/vshelper/disabled\"
858 * disable only this message by executing
859 | touch \"$__CONFDIR/.defaults/apps/vshelper/warning-disabled\""
861 test -x "$solution_sysctl" || warning $"\
862 * configure the util-vserver vshelper script, e.g. by adding
863 | kernel.vshelper = $_VSHELPER
864 to /etc/sysctl.conf and rebooting the machine, or by executing
865 | echo \"$_VSHELPER\" >$proc_file"
875 ## Usage: vshelper.isEnabled [<style>] [<vserver>]
876 function vshelper.isEnabled
878 local f=${1:+$1-}disabled
879 test ! -e "$__CONFDIR"/.defaults/apps/vshelper/"$f" || return 1
880 $_VSERVER_INFO - FEATURE vshelper || return 1
881 if test -n "$2"; then
883 appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || return 0
884 test -z "$2" -o ! -e "$appdir/$f" || return 1
890 ## Usage: vshelper.isDebug [<vserver>]
891 function vshelper.isDebug
893 test ! -e "$__CONFDIR"/.defaults/apps/vshelper/debug || return 0
894 $_VSERVER_INFO - FEATURE vshelper || return 1
895 if test -n "$1"; then
897 appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || return 1
898 test ! -e "$appdir/debug" || return 0
904 function vshelper._getHandlerInternal
909 shift ## HACK: see below the note about the 'set -u' mode
911 while test "$#" -ge 2; do
916 test "$_vghi_mod" "$_vghi_obj" || continue
919 eval $_vghi_var=\$_vghi_obj
922 read _vghi_tmp <"$_vghi_obj"
923 eval $_vghi_var=:\$_vghi_tmp
925 (*) panic $"Internal error, unexpected modifier '$_vghi_mod'"
933 ## Usage: vshelper.getHandler <result-var> <vserver> <action>
934 function vshelper.getHandler
937 _vgh_appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || _vgh_appdir=
939 declare -a _vgh_search_list=( X )
940 ## HACK: when we are in 'set -u' mode, empty lists are causing errors
942 test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -x "$_vgh_appdir/$3" )
943 test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -e "$_vgh_appdir/action" )
944 _vgh_search_list=( "${_vgh_search_list[@]}" -x "$__CONFDIR"/.defaults/apps/vshelper/"$3" )
945 _vgh_search_list=( "${_vgh_search_list[@]}" -e "$__CONFDIR"/.defaults/apps/vshelper/action )
947 ! vshelper._getHandlerInternal "$1" "${_vgh_search_list[@]}" || return 0
951 ## Usage: vshelper.init <vserver> [<method> <args>*]
952 function vshelper.doInit
954 vshelper.isEnabled || return 0
957 xid=$($_VSERVER_INFO "$1" CONTEXT false) && test -n "$xid" || {
958 warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
962 local f="$__VSHELPERSTATEDIR/$xid"
969 if test -n "$2"; then
982 ## Usage: vshelper.doDestroy <vserver> <xid>
983 function vshelper.doDestroy
985 vshelper.isEnabled || return 0
987 $_RM -f "$__VSHELPERSTATEDIR/$2"
990 ## Usage: vshelper.initSync <vserver> <pipe-varname> [<method>]
991 function vshelper.initSync
994 _vis_tmpdir=$($_MKTEMPDIR vserver-stop.XXXXXX) || {
995 warning $"Failed to generate temporary directory for vshelper sync"
999 local _vis_fifo="$_vis_tmpdir"/pipe
1000 $_MKFIFO -m700 "$_vis_fifo"
1001 vshelper.doInit "$1" "${3:-sync}" "$_vis_fifo"
1005 ## Usage: vshelper.getSyncTimeout <vserver> <varname>
1006 function vshelper.getSyncTimeout
1008 local _vgst_appdir _vgst_file _vgst_tmp
1009 _vgst_appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || _vgst_appdir=
1011 findFile _vgst_file ${_vgst_appdir:+"$_vgst_appdir"/sync-timeout} "$__CONFDIR"/.defaults/apps/vshelper/sync-timeout ''
1012 test -n "$_vgst_file" || return 1
1013 read _vgst_tmp <"$_vgst_file"
1017 function vshelper.initStopSync
1019 local _iss_sync_dir=$($_MKTEMPDIR vshelper-stop-sync.XXXXXX) || {
1020 warning $"Failed to generate directory for vshelper sync"
1023 $_MKFIFO -m700 "$_iss_sync_dir/pipe"
1025 eval "$1"=\$_iss_sync_dir
1026 VSHELPER_STOP_SYNC="$_iss_sync_dir/pipe"
1027 export VSHELPER_STOP_SYNC
1030 function vshelper.waitForStopSync
1033 cat "$sync_dir/pipe" &> /dev/null
1037 function vshelper.doStopSync
1039 test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC"
1042 function _rpmFake.getCapFlags
1046 if test -n "$ctx" && ! $_VSERVER_INFO - FEATURE migrate; then
1047 set -- $($_CHCONTEXT_COMPAT --xid 1 \
1048 $_SH -c "$_CAT /proc/[0-9]*/status | $_EGREP '^(CapBset|s_context|ctxflags)'" | \
1049 $_GREP -B 1 -A 1 "^s_context: $ctx " | \
1050 $_SED -e '1,3p;d' | $_AWK '{ print $2 }')
1055 if test -n "$3"; then
1056 RPM_FAKE_CAP=$[ ~0x$1 ]
1059 RPM_FAKE_CAP=$[ ~0xd40c04ff ]
1064 function rpmFake.init
1068 vdir=$($_VSERVER_INFO "$1" VDIR) || vdir="$1"
1069 ctx=$($_VSERVER_INFO "$1" CONTEXT) || ctx=
1072 panic $"Can not find chroot environment at '$vdir' for '$1'"
1074 _rpmFake.getCapFlags "$ctx"
1076 RPM_FAKE_CHROOT=$vdir
1080 function rpmFake.exec
1082 export RPM_FAKE_CHROOT RPM_FAKE_CTX RPM_FAKE_CAP RPM_FAKE_FLAGS
1084 LD_PRELOAD=$_RPM_FAKE_SO${LD_PRELOAD:+:$LD_PRELOAD} \