run-with-tmp-session-bus.sh 1.44 KB
Newer Older
1
#! /bin/sh
2

3 4
SCRIPTNAME="$0"
WRAPPED_SCRIPT="$1"
5 6
shift

7 8
CONFIG_FILE=./tmp-session-bus.$$.conf

9
die ()
10
{
11
    echo "$SCRIPTNAME: $*" >&2
12
    rm -f "$CONFIG_FILE"
13 14 15 16 17 18 19 20 21 22 23
    exit 1
}

if test -z "$DBUS_TOP_BUILDDIR" ; then
    die "Must set DBUS_TOP_BUILDDIR"
fi

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

24 25 26
if test -z "$SOURCE_CONFIG_FILE"; then
    SOURCE_CONFIG_FILE="$DBUS_TOP_BUILDDIR/bus/session.conf";
fi
27
## create a configuration file based on the standard session.conf
28
cat $SOURCE_CONFIG_FILE |  \
29
    sed -e 's/<standard_session_servicedirs.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
30 31 32 33 34
    sed -e 's/<include.*$//g'                \
  > $CONFIG_FILE

echo "Created configuration file $CONFIG_FILE" >&2

35 36 37 38
if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
    die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
fi

39 40
PATH="$DBUS_TOP_BUILDDIR"/bus:$PATH
export PATH
41

42 43 44
## the libtool script found by the path search should already do this, but
LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
45 46 47
unset DBUS_SESSION_BUS_ADDRESS
unset DBUS_SESSION_BUS_PID

48
$DBUS_TOP_BUILDDIR/tools/dbus-run-session \
49 50 51 52
    --config-file="$CONFIG_FILE" \
    --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \
    -- \
    "$WRAPPED_SCRIPT" "$@"
53 54 55 56 57
error=$?

# clean up
rm -f "$CONFIG_FILE"
exit $error