From 198829dc2f71ebb315ee019155d68fbc40de696d Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Tue, 30 Dec 2025 18:57:37 +0100 Subject: [PATCH] package/dbus: rewrite and rename SysV init script This brings the script in line with current standards, except the expected PIDFILE value because changing the PID file path would require changing build options. The stop action now uses the PID file instead of "killall", and reload is supported using SIGHUP (with limitations described in D-Bus documentation). "--syslog" is added to the dbus-daemon arguments to ensure log messages will be available, otherwise log messages after fork may be lost. Signed-off-by: Fiona Klute Signed-off-by: Thomas Petazzoni (cherry picked from commit f51a4752801860fff5749b03d145b6d41e3283b6) Signed-off-by: Thomas Perale --- .checkpackageignore | 1 - package/dbus/S30dbus | 58 ------------------------------ package/dbus/S30dbus-daemon | 71 +++++++++++++++++++++++++++++++++++++ package/dbus/dbus.mk | 4 +-- 4 files changed, 73 insertions(+), 61 deletions(-) delete mode 100644 package/dbus/S30dbus create mode 100644 package/dbus/S30dbus-daemon diff --git a/.checkpackageignore b/.checkpackageignore index dea84e98ec..980a979f52 100644 --- a/.checkpackageignore +++ b/.checkpackageignore @@ -303,7 +303,6 @@ package/davfs2/0001-src-Makefile.am-do-not-hardcode-fstack-protector-str.patch l package/dbus-cpp/0001-gcc4.7.patch lib_patch.Upstream package/dbus-cpp/0002-cross-compile-tools.patch lib_patch.Upstream package/dbus-cpp/0003-src-pipe.c-fix-build-error-with-gcc-7.x.patch lib_patch.Upstream -package/dbus/S30dbus Shellcheck lib_sysv.Indent lib_sysv.Variables package/dc3dd/0001-no_man.patch lib_patch.Upstream package/dc3dd/0002-fix-autoreconf.patch lib_patch.Upstream package/dc3dd/0003-fix-for-glibc-2.28.patch lib_patch.Upstream diff --git a/package/dbus/S30dbus b/package/dbus/S30dbus deleted file mode 100644 index da02609f2d..0000000000 --- a/package/dbus/S30dbus +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# -# messagebus: The D-BUS systemwide message bus -# -# chkconfig: 345 97 03 -# description: This is a daemon which broadcasts notifications of system events \ -# and other messages. See http://www.freedesktop.org/software/dbus/ -# -# processname: dbus-daemon -# pidfile: /run/messagebus.pid -# - -# Create needed directories. -[ -d /run/dbus ] || mkdir -p /run/dbus -[ -d /tmp/dbus ] || mkdir -p /tmp/dbus - -RETVAL=0 - -start() { - printf "Starting system message bus: " - - dbus-uuidgen --ensure - dbus-daemon --system - RETVAL=$? - echo "done" -} - -stop() { - printf "Stopping system message bus: " - killall dbus-daemon - RETVAL=$? - echo "done" - if [ $RETVAL -eq 0 ]; then - rm -f /run/messagebus.pid - fi -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - reload) - echo "Message bus can't reload its configuration, you have to restart it" - RETVAL=$? - ;; - *) - echo "Usage: $0 {start|stop|restart|reload}" - ;; -esac -exit $RETVAL diff --git a/package/dbus/S30dbus-daemon b/package/dbus/S30dbus-daemon new file mode 100644 index 0000000000..3331b11ced --- /dev/null +++ b/package/dbus/S30dbus-daemon @@ -0,0 +1,71 @@ +#!/bin/sh + +DAEMON="dbus-daemon" +# check-package lib_sysv.Variables +PIDFILE="/run/messagebus.pid" + +start() { + printf 'Starting system %s: ' "$DAEMON" + # Create needed directories + mkdir -p /run/dbus + mkdir -p /tmp/dbus + # Generate /var/lib/dbus/machine-id if needed + dbus-uuidgen --ensure + + start-stop-daemon --start --pidfile "$PIDFILE" \ + --exec "/usr/bin/$DAEMON" \ + -- --system --syslog + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/bin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + return "$status" + fi + while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \ + --exec "/usr/bin/$DAEMON"; do + sleep 0.1 + done + rm -f "$PIDFILE" + return "$status" +} + +reload() { + printf "Reloading %s config: " "$DAEMON" + start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \ + --exec "/usr/bin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|reload|restart) + "$1" + ;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 + ;; +esac diff --git a/package/dbus/dbus.mk b/package/dbus/dbus.mk index 2002e707f0..061a341363 100644 --- a/package/dbus/dbus.mk +++ b/package/dbus/dbus.mk @@ -93,8 +93,8 @@ endef DBUS_POST_INSTALL_TARGET_HOOKS += DBUS_REMOVE_DEVFILES define DBUS_INSTALL_INIT_SYSV - $(INSTALL) -m 0755 -D package/dbus/S30dbus \ - $(TARGET_DIR)/etc/init.d/S30dbus + $(INSTALL) -m 0755 -D package/dbus/S30dbus-daemon \ + $(TARGET_DIR)/etc/init.d/S30dbus-daemon mkdir -p $(TARGET_DIR)/var/lib rm -rf $(TARGET_DIR)/var/lib/dbus