summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remote/modules/dbus/dbus.build45
-rw-r--r--remote/modules/dbus/templates/dbus.service7
2 files changed, 42 insertions, 10 deletions
diff --git a/remote/modules/dbus/dbus.build b/remote/modules/dbus/dbus.build
index 7b7e472c..c5b2d353 100644
--- a/remote/modules/dbus/dbus.build
+++ b/remote/modules/dbus/dbus.build
@@ -13,20 +13,51 @@ build() {
# Generate systemd files
mkdir -p "$MODULE_BUILD_DIR/etc/systemd/system"
- local UUIDGEN=$(find "$MODULE_BUILD_DIR" -name dbus-uuidgen -executable | head -n 1)
+ # This is ugly, as the command line arguments changed over time. Try to do the right thing (whatever that is)
+ # Need to run dbus-uuidgen first?
+ local UUIDGEN="# This line intentionally left blank"
+ if files_contain "ExecStartPre.*uuidgen" "/lib/systemd/system/dbus.service" "/usr/lib/systemd/system/dbus.service"; then
+ UUIDGEN=$(find "$MODULE_BUILD_DIR" -name dbus-uuidgen -executable | head -n 1)
+ [ -z "$UUIDGEN" ] && perror "Could not determine dbus-uuidgen location"
+ UUIDGEN="ExecStartPre=/${UUIDGEN#$MODULE_BUILD_DIR} --ensure"
+ fi
+ # Figure out daemon location
local DAEMON=$(find "$MODULE_BUILD_DIR" -name dbus-daemon -executable | head -n 1)
- local SEND=$(find "$MODULE_BUILD_DIR" -name dbus-send -executable | head -n 1)
- UUIDGEN="${UUIDGEN#$MODULE_BUILD_DIR}"
- DAEMON="${DAEMON#$MODULE_BUILD_DIR}"
- SEND="${SEND#$MODULE_BUILD_DIR}"
- [ -z "$UUIDGEN" ] && perror "Could not determine dbus-uuidgen location"
[ -z "$DAEMON" ] && perror "Could not determine dbus-daemon location"
+ DAEMON="/${DAEMON#$MODULE_BUILD_DIR}"
+ local DAEMON_ARGS=""
+ # Daemon arguments
+ if files_contain "dbus-daemon.*nopidfile" "/lib/systemd/system/dbus.service" "/usr/lib/systemd/system/dbus.service"; then
+ DAEMON_ARGS+=" --nopidfile"
+ fi
+ if files_contain "dbus-daemon.*activation=systemd" "/lib/systemd/system/dbus.service" "/usr/lib/systemd/system/dbus.service"; then
+ DAEMON_ARGS+=" --activation=systemd"
+ fi
+ if files_contain "dbus-daemon.*systemd-activation" "/lib/systemd/system/dbus.service" "/usr/lib/systemd/system/dbus.service"; then
+ DAEMON_ARGS+=" --systemd-activation"
+ fi
+ # dbus-send location
+ local SEND=$(find "$MODULE_BUILD_DIR" -name dbus-send -executable | head -n 1)
[ -z "$SEND" ] && perror "Could not determine dbus-send location"
- sed "s,%UUIDGEN%,/$UUIDGEN,g;s,%DAEMON%,/$DAEMON,g;s,%SEND%,/$SEND,g" "templates/dbus.service" \
+ SEND="/${SEND#$MODULE_BUILD_DIR}"
+ sed "s,%UUIDGEN%,$UUIDGEN,g;s,%DAEMON%,$DAEMON,g;s,%SEND%,$SEND,g;s,%DAEMON_ARGS%,$DAEMON_ARGS,g" "templates/dbus.service" \
> "$MODULE_BUILD_DIR/etc/systemd/system/dbus.service" \
|| perror "Could not generate $MODULE_BUILD_DIR/etc/systemd/system/dbus.service"
}
+
post_copy() {
:
}
+files_contain () {
+ [ $# -lt 2 ] && perror "files_contain needs at least 2 arguments (pattern, file)"
+ local PATTERN="$1"
+ shift
+ local FILE
+ for FILE in $@; do
+ [ -e "$FILE" ] || continue
+ grep -q "$PATTERN" "$FILE" && return 0 # Found
+ done
+ return 1
+}
+
diff --git a/remote/modules/dbus/templates/dbus.service b/remote/modules/dbus/templates/dbus.service
index a49d8f0f..00b721f2 100644
--- a/remote/modules/dbus/templates/dbus.service
+++ b/remote/modules/dbus/templates/dbus.service
@@ -5,8 +5,9 @@ Requires=dbus.socket
After=syslog.target
[Service]
-ExecStartPre=%UUIDGEN% --ensure
-ExecStartPre=-/bin/rm -f /run/dbus/pid
-ExecStart=%DAEMON% --system --address=systemd: --nofork --activation=systemd
+%UUIDGEN%
+ExecStartPre=-/bin/rm -f /var/run/dbus/pid
+ExecStart=%DAEMON% --system --address=systemd: --nofork %DAEMON_ARGS%
ExecReload=%SEND% --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
OOMScoreAdjust=-900
+