Debian Codegraph @

debian/procps.postinst

raw
1 #!/bin/sh
2
3 set -e
4
5 _update_sysctl() {
6 # Conditionally apply the updated sysctl configuration:
7 # - The init system must not be systemd; if it is then its own
8 # file trigger will handle this.
9 # - /proc/sys must be available.
10 # - We must not be running in a chroot, as we would then wrongly
11 # override the outer system.
12 # - We must not be running in a container, as many sysctls will
13 # not be writable and we don't know how to handle that.
14 if ! [ -d /run/systemd/system ] \
15 && [ -d /proc/sys ] \
16 && ! ischroot \
17 && ! grep -qz '^container=' /proc/1/environ; then
18 echo 'procps: Applying updated sysctl configuration'
19 sysctl -q --system || true
20 fi
21 }
22
23 if [ "$1" = "triggered" ]; then
24 shift
25 for trigger in "$@"; do
26 case "$trigger" in
27 /usr/lib/sysctl.d)
28 _update_sysctl
29 ;;
30 esac
31 done
32 exit 0
33 fi
34
35 # update alternative, if it exists
36 check_alternatives() {
37 BINNAME="$1"
38 BINPATH="$2"
39 MANSEC="$3"
40 if [ -r "$BINPATH"/"$BINNAME".procps ] ; then
41 update-alternatives --install "$BINPATH"/"$BINNAME" "$BINNAME" \
42 "$BINPATH"/"$BINNAME".procps 50 \
43 --slave /usr/share/man/man"$MANSEC"/"$BINNAME"."$MANSEC".gz "$BINNAME"."$MANSEC".gz \
44 /usr/share/man/man"$MANSEC"/"$BINNAME".procps."$MANSEC".gz
45 fi
46 }
47
48 case "$1" in
49 configure|abort-remove|abort-deconfigure)
50 # Do alternatives for uptime vmstat w and ps, if required
51 check_alternatives "uptime" "/usr/bin" "1"
52 check_alternatives "vmstat" "/usr/bin" "8"
53 check_alternatives "w" "/usr/bin" "1"
54 check_alternatives "ps" "/bin" "1"
55 ;;
56 esac
57
58 #DEBHELPER#