diff options
author | Colin Walters <walters@verbum.org> | 2005-03-17 17:48:29 +0000 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2005-03-17 17:48:29 +0000 |
commit | a65587676f6791ff6a7c9ed98bbc53d740f51fa8 (patch) | |
tree | 1e5fb5030cf55dc63dc388e6da4a7918dfa9251f /tools/run-with-tmp-session-bus.sh | |
parent | 6180ae6941aea083f5b8f3c4d3f16c928935bcaf (diff) |
2005-03-17 Colin Walters <walters@verbum.org>
* bus/print-introspect.c: Move to tools/.
* bus/run-with-tmp-session-bus.sh: Ditto.
* glib/Makefile.am (dbus-glib-bindings.h): Move
generation to tools/Makefile.am.
* test/glib/run-test.sh: Update to handle move
of run-with-tmp-session-bus.sh.
* test/glib/test-service-glib.c: Update to handle
move of dbus-glib-bindings.h.
* tools/print-introspect.c: Moved here
from bus/, and ported to GLib bindings.
* tools/run-with-tmp-session-bus.sh: Moved here
from bus/.
* tools/Makefile.am: Generate dbus-glib-bindings.h
and dbus-bus-introspect.xml here.
* tools/.cvsignore, glib/.cvsignore, bus/.cvsignore:
Update.
Diffstat (limited to 'tools/run-with-tmp-session-bus.sh')
-rwxr-xr-x | tools/run-with-tmp-session-bus.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh new file mode 100755 index 00000000..ce077d72 --- /dev/null +++ b/tools/run-with-tmp-session-bus.sh @@ -0,0 +1,65 @@ +#! /bin/bash + +SCRIPTNAME=$0 +WRAPPED_SCRIPT=$1 +shift + +function die() +{ + if ! test -z "$DBUS_SESSION_BUS_PID" ; then + echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 + kill -9 $DBUS_SESSION_BUS_PID + fi + echo $SCRIPTNAME: $* >&2 + exit 1 +} + +if test -z "$DBUS_TOP_BUILDDIR" ; then + die "Must set DBUS_TOP_BUILDDIR" +fi + +## convenient to be able to ctrl+C without leaking the message bus process +trap 'die "Received SIGINT"' SIGINT + +CONFIG_FILE=./run-with-tmp-session-bus.conf +SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" +ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` +echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 + +## create a configuration file based on the standard session.conf +cat $DBUS_TOP_BUILDDIR/bus/session.conf | \ + sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \ + sed -e 's/<include.*$//g' \ + > $CONFIG_FILE + +echo "Created configuration file $CONFIG_FILE" >&2 + +export PATH=$DBUS_TOP_BUILDDIR/bus:$PATH +## the libtool script found by the path search should already do this, but +export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH + +unset DBUS_SESSION_BUS_ADDRESS +unset DBUS_SESSION_BUS_PID + +echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2 + +eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE` + +if test -z "$DBUS_SESSION_BUS_PID" ; then + die "Failed to launch message bus for introspection generation to run" +fi + +echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2 + +# Execute wrapped script +echo "Running $WRAPPED_SCRIPT $@" >&2 +$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed" + +kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2 + +sleep 2 + +## be sure it really died +kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true + +exit 0 |