]> git.proxmox.com Git - pve-manager.git/blob - debian/postinst
postinst: start/restart units like dh_start
[pve-manager.git] / debian / postinst
1 #!/bin/bash
2
3 # Abort if any command returns an error value
4 set -e
5
6 # This script is called as the last step of the installation of the
7 # package. All the package's files are in place, dpkg has already
8 # done its automatic conffile handling, and all the packages we depend
9 # of are already fully installed and configured.
10
11 case "$1" in
12 triggered)
13 # We don't print a status message here, as dpkg already said
14 # "Processing triggers for ...".
15
16 # test if /etc/pve is mounted; else simple exit to avoid
17 # error during updates
18 test -f /etc/pve/local/pve-ssl.pem || exit 0;
19 test -e /proxmox_install_mode && exit 0;
20
21 deb-systemd-invoke reload-or-try-restart pvedaemon.service
22 deb-systemd-invoke reload-or-try-restart pvestatd.service
23 deb-systemd-invoke reload-or-try-restart pveproxy.service
24 deb-systemd-invoke reload-or-try-restart spiceproxy.service
25
26 exit 0;;
27
28 configure)
29 # Configure this package. If the package must prompt the user for
30 # information, do it here.
31
32 mkdir /etc/pve 2>/dev/null || true
33
34 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
35 mkdir -p /var/lib/pve-manager/apl-info
36 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
37 pveam update || true
38 fi
39
40 if ! test -f /root/.forward || ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then
41 echo '|/usr/bin/pvemailforward' >>/root/.forward
42 fi
43
44 systemctl --system daemon-reload >/dev/null || true
45
46 # same as dh_systemd_enable (code copied)
47
48 UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvesr.timer pve-daily-update.timer"
49 NO_RESTART_UNITS="pvenetcommit.service pve-guests.service"
50
51 for unit in ${UNITS} ${NO_RESTART_UNITS}; do
52 deb-systemd-helper unmask "$unit" >/dev/null || true
53
54 # was-enabled defaults to true, so new installations run enable.
55 if deb-systemd-helper --quiet was-enabled "$unit"; then
56 # Enables the unit on first installation, creates new
57 # symlinks on upgrades if the unit file has changed.
58 deb-systemd-helper enable "$unit" >/dev/null || true
59 else
60 # Update the statefile to add new symlinks (if any), which need to be
61 # cleaned up on purge. Also remove old symlinks.
62 deb-systemd-helper update-state "$unit" >/dev/null || true
63 fi
64 done
65
66 if test ! -e /proxmox_install_mode; then
67 # modeled after code generated by dh_start
68 for unit in ${UNITS}; do
69 if test -n "$2"; then
70 dh_action="reload-or-try-restart";
71 else
72 dh_action="start"
73 fi
74 deb-systemd-invoke $dh_action "$unit"
75 done
76 fi
77
78 if test -n "$2"; then
79 # "$2" is the most recently configured version
80
81 if dpkg --compare-versions "$2" '<=' '5.0-23'; then
82 # 5.0-23 temporarily reverted the removal of the startcom CA in
83 # ca-certificates; we've since switched to let's encrypt
84 update-ca-certificates >/dev/null 2>&1
85 fi
86
87 if dpkg --compare-versions "$2" '<=' '5.1-47'; then
88 # remove cron update job, superseded by systemd timer
89 rm -f /etc/cron.d/pveupdate
90
91 # remove old/unused init.d files
92 OLD_INITD_FILES="pvebanner pvenetcommit pve-manager pvedaemon pveproxy pvestatd spiceproxy"
93 for f in ${OLD_INITD_FILES}; do rm -f "/etc/init.d/$f"; done
94 fi
95 fi
96 ;;
97
98 abort-upgrade|abort-remove|abort-deconfigure)
99 ;;
100
101 *) echo "$0: didn't understand being called with \`$1'" 1>&2
102 exit 0;;
103 esac
104
105 exit 0