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 <fiona.klute@gmx.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit f51a4752801860fff5749b03d145b6d41e3283b6)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
Fiona Klute
2025-12-30 18:57:37 +01:00
committed by Thomas Perale
parent 6bfb1a51c4
commit 5826d197fb
4 changed files with 73 additions and 61 deletions

View File

@@ -324,7 +324,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

View File

@@ -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

View File

@@ -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

View File

@@ -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