Debian Codegraph @

debian/dbus-broker.postinst

raw
1 #!/bin/sh
2
3 set -e
4
5 reboot_required() {
6 if [ "$1" -eq 1 ]; then
7 echo "Upgrading to a newer dbus-broker version requires a reboot:" >&2
8 else
9 echo "Replacing the running dbus-daemon with dbus-broker requires a reboot:" >&2
10 fi
11 echo "please reboot the system when convenient." >&2
12
13 # Trigger an update notification that recommends a reboot.
14 touch /var/run/reboot-required || true
15
16 if ! grep -Fqsx dbus-broker /run/reboot-required.pkgs; then
17 echo dbus-broker >> /run/reboot-required.pkgs || true
18 fi
19 }
20
21 if [ "$1" = triggered ] && systemctl --quiet is-active dbus-broker.service; then
22 systemctl reload dbus-broker || true
23 exit 0
24 fi
25
26 if [ "$1" = configure ]; then
27 # Restarting the system bus is not supported yet. On upgrades do
28 # not restart the broker but recomment a reboot if the service is
29 # running. Replacing dbus-deamon also requires a reboot.
30
31 # dbus-daemon depends on systemd but if we are replacing
32 # dbus-broker systemd may not be running yet, so fallback to sysv-utils.
33 if [ -z "$2" ]; then
34 if [ -d /run/systemd/system ]; then
35 # Don't fallback to sysvs-utils if definitely running under systemd
36 if systemctl --quiet is-active dbus.service; then
37 reboot_required 0
38 fi
39 elif command -v pidof >/dev/null 2>&1 && pidof -c /bin/dbus-daemon /usr/bin/dbus-daemon >/dev/null; then
40 reboot_required 0
41 fi
42 fi
43
44 # dbus-broker depends on systemd thus we can use its functionality
45 if [ -n "$2" ] && systemctl --quiet is-active dbus-broker.service; then
46 reboot_required 1
47
48 # begin-remove-after: released:trixie
49 # When updating from versions << 37 the service type will change,
50 # but given we cannot restart the service we need to add an ephemeral
51 # override, otherwise reloading will be stuck and time out, as the
52 # RELOADING=1 sd_notify message won't be sent to the system manager.
53 if dpkg --compare-versions "$2" lt 37~; then
54 mkdir -p /run/systemd/system/dbus-broker.service.d/
55 cat <<EOF >/run/systemd/system/dbus-broker.service.d/debian-type-override.conf
56 [Service]
57 Type=notify
58 ExecReload=/usr/bin/busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig
59 EOF
60 systemctl daemon-reload || true
61 fi
62 # end-remove-after
63
64 # In case we got new configuration files
65 systemctl reload dbus-broker || true
66 fi
67 fi
68
69 #DEBHELPER#