summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-09-21 02:20:27 -0700
committerPatrick Ohly <patrick.ohly@intel.com>2016-09-26 12:58:27 +0200
commitf2c9838e97f8b7e732dc53ce986daf3f2d9bac66 (patch)
treecb5dcb7d77d0868e16f57b08c3a4daff479d01e8
parent9103a70c72d7f4aed0959963fc18b0f597af6572 (diff)
syncevo-dbus-server-startup.sh.in: optional start via D-Bus activation
With the recent change ("Add a systemd user service as a backend for the D-Bus session services"), activating syncevo-dbus-server via D-Bus will integrate better with systemd. When auto-starting via the .desktop file, we can do the same by activating via D-Bus. We use dbus-send for that, if available. A recent busctl from systemd could also be used, but for example the one in Debian Jessie is still to old. Better use dbus-send. Directly starting the binary is used as fallback. Based on a patch from Simon McVittie.
-rwxr-xr-xsrc/dbus/server/syncevo-dbus-server-startup.sh.in19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/dbus/server/syncevo-dbus-server-startup.sh.in b/src/dbus/server/syncevo-dbus-server-startup.sh.in
index 6f9d7ba6..cd74dac9 100755
--- a/src/dbus/server/syncevo-dbus-server-startup.sh.in
+++ b/src/dbus/server/syncevo-dbus-server-startup.sh.in
@@ -1,3 +1,20 @@
#! /bin/sh
sleep 120
-exec @libexecdir@/syncevo-dbus-server @SYNCEVO_DBUS_SERVER_ARGS@ 2>/dev/null 1>&1
+
+
+if type dbus-send >/dev/null 2>&1; then
+ # Use D-Bus activation to start it, to take advantage of
+ # systemd service management.
+ dbus-send \
+ --session \
+ --type=method_call \
+ --print-reply \
+ --dest=org.freedesktop.DBus \
+ /org/freedesktop/DBus \
+ org.freedesktop.DBus.StartServiceByName \
+ string:org.syncevolution \
+ uint32:0
+else
+ # Fall back to direct invocation.
+ exec @libexecdir@/syncevo-dbus-server @SYNCEVO_DBUS_SERVER_ARGS@ 2>/dev/null 1>&1
+fi