]> git.proxmox.com Git - pve-manager.git/blob - debian/postinst
postinst: removing old APL dir is obsolete
[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 # remove old cron.daily update job to randomize it
36 if test -e /etc/cron.daily/pve; then
37 echo "Remove old update script from cron.daily"
38 rm /etc/cron.daily/pve
39 fi
40
41 if dpkg --compare-versions "$2" '<=' '5.1-47'; then
42 # remove old/unused init.d files
43 OLD_INITD_FILES="pvebanner pvenetcommit pve-manager pvedaemon pveproxy pvestatd spiceproxy"
44 for f in ${OLD_INITD_FILES}; do rm -f "/etc/init.d/$f"; done
45 fi
46
47 # create new daily randomize update cronjob if not exist
48 MIN="$(shuf -i 0-59 -n 1)"
49 HOUR="$(shuf -i 2-5 -n 1)"
50 cat <<EOF >/etc/cron.d/pveupdate
51 # automatically generated - do not edit
52 ${MIN} ${HOUR} * * * root /usr/bin/pveupdate
53 EOF
54
55 if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then
56 mkdir -p /var/lib/pve-manager/apl-info
57 cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com
58 pveam update || true
59 fi
60
61 if test -f /root/.forward; then
62 if ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then
63 echo -e "|/usr/bin/pvemailforward\n$(cat /root/.forward)" >/root/.forward.tmp
64 mv /root/.forward.tmp /root/.forward
65 fi
66 else
67 echo '|/usr/bin/pvemailforward' >/root/.forward
68 fi
69
70 # disable fancy init messages (bad with bootlogd)
71 test -f /etc/lsb-base-logging.sh || echo "FANCYTTY=0" >/etc/lsb-base-logging.sh
72
73 if [ -f /etc/systemd/system/ceph.service ]; then
74 md5=$(md5sum /etc/systemd/system/ceph.service)
75 if [[ "$md5" == "21b2e7a7c4ffcf92ad0ec2c905e88e5b /etc/systemd/system/ceph.service" ]]; then
76 echo "Updating PVE ceph.service to correct install target.."
77 cp /usr/share/doc/pve-manager/examples/ceph.service /etc/systemd/system/ceph.service
78 systemctl --system daemon-reload >/dev/null || true
79 systemctl --system disable ceph.service
80 systemctl --system enable ceph.service
81 echo " done"
82 fi
83 fi
84
85 systemctl --system daemon-reload >/dev/null || true
86
87 # same as dh_systemd_enable (code copied)
88
89 for timer in pvesr; do
90 deb-systemd-helper unmask $timer.timer >/dev/null || true
91
92 # was-enabled defaults to true, so new installations run enable.
93 if deb-systemd-helper --quiet was-enabled $timer.timer; then
94 # Enables the unit on first installation, creates new
95 # symlinks on upgrades if the unit file has changed.
96 deb-systemd-helper enable $timer.timer >/dev/null || true
97 else
98 # Update the statefile to add new symlinks (if any), which need to be
99 # cleaned up on purge. Also remove old symlinks.
100 deb-systemd-helper update-state $timer.timer >/dev/null || true
101 fi
102 done
103
104 for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-guests; do
105 deb-systemd-helper unmask $service.service >/dev/null || true
106
107 # was-enabled defaults to true, so new installations run enable.
108 if deb-systemd-helper --quiet was-enabled $service.service; then
109 # Enables the unit on first installation, creates new
110 # symlinks on upgrades if the unit file has changed.
111 deb-systemd-helper enable $service.service >/dev/null || true
112 else
113 # Update the statefile to add new symlinks (if any), which need to be
114 # cleaned up on purge. Also remove old symlinks.
115 deb-systemd-helper update-state $service.service >/dev/null || true
116 fi
117 done
118
119 if test ! -e /proxmox_install_mode; then
120
121 for service in pvedaemon pveproxy spiceproxy pvestatd; do
122 deb-systemd-invoke reload-or-restart $service
123 done
124
125 deb-systemd-invoke start pvesr.timer >/dev/null || true
126 fi
127
128 # rewrite banner
129 test -e /proxmox_install_mode || pvebanner || true
130
131 #a2ensite pve.conf >/dev/null 2>&1
132
133 # There are three sub-cases:
134 if test "${2+set}" != set; then
135 # We're being installed by an ancient dpkg which doesn't remember
136 # which version was most recently configured, or even whether
137 # there is a most recently configured version.
138 :
139
140 elif test -z "$2" -o "$2" = "<unknown>"; then
141 # The package has not ever been configured on this system, or was
142 # purged since it was last configured.
143 :
144
145 else
146 # Version $2 is the most recently configured version of this
147 # package.
148 if dpkg --compare-versions "$2" '<=' '5.0-23'; then
149 # 5.0-23 temporarily reverted the removal of the startcom CA in
150 # ca-certificates; we've since switched to let's encrypt
151 update-ca-certificates >/dev/null 2>&1
152 fi
153
154 fi ;;
155 abort-upgrade)
156 # Back out of an attempt to upgrade this package FROM THIS VERSION
157 # to version $2. Undo the effects of "prerm upgrade $2".
158 :
159
160 ;;
161 abort-remove)
162 if test "$2" != in-favour; then
163 echo "$0: undocumented call to \`postinst $*'" 1>&2
164 exit 0
165 fi
166 # Back out of an attempt to remove this package, which was due to
167 # a conflict with package $3 (version $4). Undo the effects of
168 # "prerm remove in-favour $3 $4".
169 :
170
171 ;;
172 abort-deconfigure)
173 if test "$2" != in-favour -o "$5" != removing; then
174 echo "$0: undocumented call to \`postinst $*'" 1>&2
175 exit 0
176 fi
177 # Back out of an attempt to deconfigure this package, which was
178 # due to package $6 (version $7) which we depend on being removed
179 # to make way for package $3 (version $4). Undo the effects of
180 # "prerm deconfigure in-favour $3 $4 removing $6 $7".
181 :
182
183 ;;
184 *) echo "$0: didn't understand being called with \`$1'" 1>&2
185 exit 0;;
186 esac
187
188 exit 0