-#! /bin/bash
+#! /usr/lib/util-vserver/sigexec /bin/bash
# Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
case "$ACTION" in
(restart)
logging $"Restarting vserver '$VSERVER'"
+ spawn killContext "$XID"
execute $_VSERVER --defaulttty "$VSERVER" restart
;;
(halt|poweroff)
logging $"Stopping vserver '$VSERVER'"
+ spawn killContext "$XID"
execute $_VSERVER --defaulttty "$VSERVER" stop
;;
(swsusp)
exit 1
esac
;;
+
+ (async)
+ spawn killContext "$XID"
+ ;;
(sync)
local f=${METHOD_ARGS[0]}
- test "$f" ||
+ test -n "$f" ||
panic $"Insufficent arguments for method '$method' and vserver '$VSERVER'"
test -p "$f" ||
panic $"File '$f' which is required for synchronisation of vserver '$VSERVER' is not a pipe"
+ spawn killContext "$XID"
echo "$ACTION" >"$f"
;;
(*)
local script
- findObject -x script "$CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$PKGLIBDIR"/vshelper-methods/"$method" ''
+ findObject -x script "$__CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$__PKGLIBDIR"/vshelper-methods/"$method" ''
- test '$script' || {
+ test -n '$script' || {
warning $"No handler for internal method '$method' found"
exit 1
}
#===========
+test "$1" != '--version' || showVersion
+test "$1" != '--help' || showHelp
+
if ! tty -s; then
- findObject -e _VS_LOGFILE "$CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
- findObject -e _VS_ERRFILE "$CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
+ findObject -e _VS_LOGFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
+ findObject -e _VS_ERRFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
exec </dev/null
exec >>$_VS_LOGFILE
exec 2>>$_VS_ERRFILE
fi
-
-logging "$(date): vshelper $*"
-test "$1" != '--version' || showVersion
-test "$1" != '--help' || showHelp
+logging "$(date): vshelper $*"
+
test "$#" -ge 2 ||
panic $"vshelper called with missing arguments; try '--help' for more information"
+
vshelper.isEnabled || exit 0
+! vshelper.isDebug || set -x
set -eu
panic $"vshelper functionality not supported by kernel"
fi
+findObject -x delegate "$__CONFDIR"/.defaults/apps/vshelper-delegate/"$ACTION" "$__PKGLIBDIR"/vshelper-delegate/"$ACTION" ''
+test -e "$delegate" && exec -a "$ACTION" "$delegate" "$@"
this_xid=$($_VSERVER_INFO - XID)
pxid=
while true; do
pxid=$($_VSERVER_INFO "$responsible_xid" PXID) || break
test "$pxid" -ne "$this_xid" || break
- xid=$responsible_xid
+ responsible_xid=$pxid
done
vserver_id=$($_VSERVER_INFO "$responsible_xid" ID) ||
ARGS=( "$@" )
declare -a state
-getFileArray state "$VSHELPERSTATEDIR/$XID" && test ${#state[@]} -ge 2 || {
+getFileArray state "$__VSHELPERSTATEDIR/$XID" && test ${#state[@]} -ge 2 || {
logging "'vshelper' not configured for xid '$XID'"
exit 0
}
fi
case "$method" in
- (default) doDefaultMethod "$@";;
- (sync) doInternalMethod "$method" "$@";;
- (*) panic $"Unknown method '$method' used by vserver '$VSERVER'";;
+ (default) doDefaultMethod "$@";;
+ (sync|async) doInternalMethod "$method" "$@";;
+ (*) panic $"Unknown method '$method' used by vserver '$VSERVER'";;
esac