File: systemd.postinst

package info (click to toggle)
systemd 260.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 115,380 kB
  • sloc: ansic: 741,720; xml: 122,315; sh: 36,676; python: 36,497; cpp: 947; makefile: 277; awk: 126; lisp: 13; sed: 1
file content (87 lines) | stat: -rw-r--r-- 2,564 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh

set -e

_systemctl() {
    if [ -z "$DPKG_ROOT" ] && [ -d /run/systemd/system ]; then
        systemctl "$@"
    fi
}

_update_catalog() {
    journalctl ${DPKG_ROOT:+--root="$DPKG_ROOT"} --update-catalog || true
}

_update_binfmt() {
    if [ "$(_systemctl show -P LoadState systemd-binfmt.service)" != "masked" ]; then
        _systemctl restart systemd-binfmt.service || true
    fi
}

_update_sysctl() {
    if [ "$(_systemctl show -P LoadState systemd-sysctl.service)" != "masked" ]; then
        _systemctl restart systemd-sysctl.service || true
    fi
}

_restart_managers() {
    if [ -z "$DPKG_ROOT" ] && [ -d /run/systemd/system ]; then
        # Re-exec user instances so that running user managers are updated too.
        # Note that this is asynchronous, but we can't use
        # D-Bus as dbus-user-session is not guaranteed to be available.
        deb-systemd-invoke --user --no-dbus daemon-reexec || true
        deb-systemd-invoke --no-dbus daemon-reexec || true
    fi
}

# Update Message Catalogs database and binfmt registrations in response to dpkg triggers
if [ "$1" = "triggered" ]; then
    shift
    for trigger in $@; do
        case $trigger in
            /usr/lib/systemd/catalog)
                _update_catalog
                ;;
            /usr/lib/binfmt.d)
                _update_binfmt
                ;;
            /usr/lib/sysctl.d)
                _update_sysctl
                ;;
            libc-upgrade)
                _restart_managers
                ;;
        esac
    done
    exit 0
fi

# Enable getty, remote-fs.target and systemd-pstore by default on new installs
if [ -z "$2" ]; then
    systemctl ${DPKG_ROOT:+--root="$DPKG_ROOT"} enable remote-fs.target || true
    systemctl ${DPKG_ROOT:+--root="$DPKG_ROOT"} enable systemd-pstore.service || true
fi

# This is no longer statically enabled since v260
# Enable autovt@.service and getty@tty1 on upgrades and new installs
if dpkg --compare-versions "$2" lt "260~rc4-2~"; then
    systemctl ${DPKG_ROOT:+--root="$DPKG_ROOT"} enable getty@.service || true
fi

# Create /etc/machine-id
systemd-machine-id-setup ${DPKG_ROOT:+--root="$DPKG_ROOT"}

# Enable persistent journal, in auto-mode, by default on new installs
if [ -z "$2" ]; then
    mkdir -p "$DPKG_ROOT/var/log/journal"
fi

# skip daemon-reexec and try-restarts during shutdown to avoid hitting LP: #1803391
if [ -n "$2" ] && [ "$(systemctl is-system-running)" != "stopping" ]; then
    _restart_managers
fi

# Initial update of the Message Catalogs database
_update_catalog

#DEBHELPER#