return 0
}
+## Usage: colorize <style> <command>
+function colorize
+{
+ local style=$1
+ shift
+
+ if ! tty -s; then
+ "$@"
+ else
+ local cfile
+ findFile cfile "$CONFDIR"/.defaults/styles/"$style" ''
+ if test "$cfile"; then
+ cat "$cfile"
+ else
+ case "$style" in
+ (bold) echo -ne "\e[1m";;
+ (emph) echo -ne "\e[34m";;
+ (info) echo -ne "\e[0;34m";;
+ (warn*) echo -ne "\e[1;31m";;
+ (error) echo -ne "\e[1;33;41m";;
+ (*) ;;
+ esac
+ fi
+
+ "$@"
+ echo -ne "\e[m"
+ fi
+}
+
+## Usage: xtermTitle <title>
+function xtermTitle
+{
+ tty -s || return 0
+ echo -ne "\e]0;$@\007"
+}
+
_VS_LOCKS=''
## Usage: lock <lockfile> [<timeout>]
function lock
rm -f $tmp
mkfifo -m600 $tmp
- sleep 10
$_LOCKFILE "$1" $tmp $2 &
- cat <$tmp >/dev/null
+ grep -q true $tmp 2>/dev/null || return 1
_VS_LOCKS="$! $_VS_LOCKS"
}
_pkgMountBindDir "$RPMETCDIR" /etc/rpm
test "$RPMLIBDIR" = "/" || _pkgMountBindDir "$RPMLIBDIR" /usr/lib/rpm
- "$_SECURE_MOUNT" --chroot "$VDIR" -n --secure --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
+ pushd "$VDIR" >/dev/null
+
+ "$_SECURE_MOUNT" --chroot -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
test -z "$WORKAROUND_106057" || mount -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
test -e "$VDIR"/proc/self/status || \
- "$_SECURE_MOUNT" --chroot "$VDIR" -n --secure -t proc none /proc
+ "$_SECURE_MOUNT" --chroot -n -t proc none /proc
+
+ popd >/dev/null
}
function _pkgSetEnvBase
local ctx=
isAvoidNamespace "$1" || \
- ctx=$( $_VSERVER_INFO "$1" CONTEXT t ) || ctx=
+ ctx=$( $_VSERVER_INFO "$1" CONTEXT f ) || ctx=
shift
if test "$ctx"; then
fi
}
+## Usage: setDefaultTTY <vdir> [<fallback-tty>]
+function setDefaultTTY
+{
+ local cfgdir ttyname
+
+ cfgdir=$($_VSERVER_INFO "$1" APPDIR init) || cfgdir=
+ findObject -e ttyname \
+ ${cfgdir:+"$cfgdir"/tty} \
+ "$CONFDIR/.defaults/apps/init/tty" \
+ $2 /dev/null
+
+ exec <$ttyname
+ exec &>$ttyname
+}
+
## Usage: pkgmgmt.guessStyle <vserver> <resultvar>
function pkgmgmt.guessStyle()
{
test -d "$VSHELPERSTATEDIR" || {
warnings=( "${warnings[@]}"
$"\
-The vshelper state-directory '$VSHELPERSTATEDIR' does not exist;
- since it is created by 'make install', this indicates a serious
- problem with your util-vserver installation" )
+The vshelper state-directory '$VSHELPERSTATEDIR' does not exist; since
+it is created by 'make install', this indicates a serious problem with
+your util-vserver installation" )
solution_disable=1
}
{
vshelper.isEnabled || return 0
- local xid=$($_VSERVER_INFO "$1" CONTEXT false) || {
- warning $"vshelper.init: can not determine xid of vserver '$vserver'"
+ local xid=$($_VSERVER_INFO "$1" CONTEXT false) && test "$xid" || {
+ warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
return 1
}
local fifo="$tmpdir"/pipe
mkfifo -m700 "$fifo"
- vshelper.doInit "$VSERVER_DIR" sync "$fifo"
+ vshelper.doInit "$1" sync "$fifo"
eval $2=\$fifo
}