#!/bin/sh set -e reboot_required() { if [ "$1" -eq 1 ]; then echo "Upgrading to a newer dbus-broker version requires a reboot:" >&2 else echo "Replacing the running dbus-daemon with dbus-broker requires a reboot:" >&2 fi echo "please reboot the system when convenient." >&2 # Trigger an update notification that recommends a reboot. touch /var/run/reboot-required || true if ! grep -Fqsx dbus-broker /run/reboot-required.pkgs; then echo dbus-broker >> /run/reboot-required.pkgs || true fi } if [ "$1" = triggered ] && systemctl --quiet is-active dbus-broker.service; then systemctl reload dbus-broker || true exit 0 fi if [ "$1" = configure ]; then # Restarting the system bus is not supported yet. On upgrades do # not restart the broker but recomment a reboot if the service is # running. Replacing dbus-deamon also requires a reboot. # dbus-daemon depends on systemd but if we are replacing # dbus-broker systemd may not be running yet, so fallback to sysv-utils. if [ -z "$2" ]; then if [ -d /run/systemd/system ]; then # Don't fallback to sysvs-utils if definitely running under systemd if systemctl --quiet is-active dbus.service; then reboot_required 0 fi elif command -v pidof >/dev/null 2>&1 && pidof -c /bin/dbus-daemon /usr/bin/dbus-daemon >/dev/null; then reboot_required 0 fi fi # dbus-broker depends on systemd thus we can use its functionality if [ -n "$2" ] && systemctl --quiet is-active dbus-broker.service; then reboot_required 1 # begin-remove-after: released:trixie # When updating from versions << 37 the service type will change, # but given we cannot restart the service we need to add an ephemeral # override, otherwise reloading will be stuck and time out, as the # RELOADING=1 sd_notify message won't be sent to the system manager. if dpkg --compare-versions "$2" lt 37~; then mkdir -p /run/systemd/system/dbus-broker.service.d/ cat </run/systemd/system/dbus-broker.service.d/debian-type-override.conf [Service] Type=notify ExecReload=/usr/bin/busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig EOF systemctl daemon-reload || true fi # end-remove-after # In case we got new configuration files systemctl reload dbus-broker || true fi fi #DEBHELPER#