]> git.proxmox.com Git - pve-manager.git/blob - debian/postinst
pveupdate: replace cron job with systemd timer
[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 # Note: reload-or-try-restart fails if service is not active
22 systemctl --quiet is-active pvedaemon.service && deb-systemd-invoke reload-or-try-restart pvedaemon.service
23 systemctl --quiet is-active pvestatd.service && deb-systemd-invoke reload-or-try-restart pvestatd.service
24 systemctl --quiet is-active pveproxy.service && deb-systemd-invoke reload-or-try-restart pveproxy.service
25 systemctl --quiet is-active spiceproxy.service && deb-systemd-invoke reload-or-try-restart spiceproxy.service
26
27 exit 0;;
28
29 configure)
30 # Configure this package. If the package must prompt the user for
31 # information, do it here.
32
33 mkdir /etc/pve 2>/dev/null || true
34
35 if dpkg --compare-versions "$2" '<=' '5.1-47'; then
36 # remove cron update job, superseded by systemd timer
37 rm -f /etc/cron.d/pveupdate
38
39 # remove old/unused init.d files
40 OLD_INITD_FILES="pvebanner pvenetcommit pve-manager pvedaemon pveproxy pvestatd spiceproxy"
41 for f in ${OLD_INITD_FILES}; do rm -f "/etc/init.d/$f"; done
42 fi
43
44 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
45 mkdir -p /var/lib/pve-manager/apl-info
46 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
47 pveam update || true
48 fi
49
50 if ! test -f /root/.forward || ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then
51 echo '|/usr/bin/pvemailforward' >>/root/.forward
52 fi
53
54 systemctl --system daemon-reload >/dev/null || true
55
56 # same as dh_systemd_enable (code copied)
57
58 for timer in pvesr; do
59 deb-systemd-helper unmask $timer.timer >/dev/null || true
60
61 # was-enabled defaults to true, so new installations run enable.
62 if deb-systemd-helper --quiet was-enabled $timer.timer; then
63 # Enables the unit on first installation, creates new
64 # symlinks on upgrades if the unit file has changed.
65 deb-systemd-helper enable $timer.timer >/dev/null || true
66 else
67 # Update the statefile to add new symlinks (if any), which need to be
68 # cleaned up on purge. Also remove old symlinks.
69 deb-systemd-helper update-state $timer.timer >/dev/null || true
70 fi
71 done
72
73 for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests; do
74 deb-systemd-helper unmask $service.service >/dev/null || true
75
76 # was-enabled defaults to true, so new installations run enable.
77 if deb-systemd-helper --quiet was-enabled $service.service; then
78 # Enables the unit on first installation, creates new
79 # symlinks on upgrades if the unit file has changed.
80 deb-systemd-helper enable $service.service >/dev/null || true
81 else
82 # Update the statefile to add new symlinks (if any), which need to be
83 # cleaned up on purge. Also remove old symlinks.
84 deb-systemd-helper update-state $service.service >/dev/null || true
85 fi
86 done
87
88 if test ! -e /proxmox_install_mode; then
89
90 for service in pvedaemon pveproxy spiceproxy pvestatd; do
91 deb-systemd-invoke reload-or-restart $service
92 done
93
94 deb-systemd-invoke start pvesr.timer >/dev/null || true
95 fi
96
97 if test -z "$2"; then
98 : # no old version, nothing to do
99 else
100 # "$2" is the most recently configured version
101 if dpkg --compare-versions "$2" '<=' '5.0-23'; then
102 # 5.0-23 temporarily reverted the removal of the startcom CA in
103 # ca-certificates; we've since switched to let's encrypt
104 update-ca-certificates >/dev/null 2>&1
105 fi
106 fi
107 ;;
108
109 abort-upgrade|abort-remove|abort-deconfigure)
110 ;;
111
112 *) echo "$0: didn't understand being called with \`$1'" 1>&2
113 exit 0;;
114 esac
115
116 exit 0