]>
Commit | Line | Data |
---|---|---|
7aa2bc3b | 1 | #!/bin/bash |
aff192e6 DM |
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 | # The following idempotent stuff doesn't generally need protecting | |
12 | # against being run in the abort-* cases. | |
13 | ||
14 | # Use debconf. (installs templates) | |
15 | . /usr/share/debconf/confmodule | |
16 | # all done with debconf here. | |
17 | db_stop | |
18 | ||
19 | case "$1" in | |
20 | triggered) | |
21 | # We don't print a status message here, as dpkg already said | |
22 | # "Processing triggers for ...". | |
23 | ||
099e5477 DM |
24 | # test if /etc/pve is mounted; else simple exit to avoid |
25 | # error during updates | |
26 | test -f /etc/pve/local/pve-ssl.pem || exit 0; | |
6675a064 | 27 | test -e /proxmox_install_mode && exit 0; |
81019d9d DM |
28 | |
29 | # Note: reload-or-try-restart fails if service is not active | |
30 | systemctl --quiet is-active pvedaemon.service && deb-systemd-invoke reload-or-try-restart pvedaemon.service | |
31 | systemctl --quiet is-active pvestatd.service && deb-systemd-invoke reload-or-try-restart pvestatd.service | |
32 | systemctl --quiet is-active pveproxy.service && deb-systemd-invoke reload-or-try-restart pveproxy.service | |
33 | systemctl --quiet is-active spiceproxy.service && deb-systemd-invoke reload-or-try-restart spiceproxy.service | |
aff192e6 DM |
34 | |
35 | exit 0;; | |
36 | ||
37 | configure) | |
38 | # Configure this package. If the package must prompt the user for | |
39 | # information, do it here. | |
40 | ||
41 | mkdir /etc/pve 2>/dev/null || true | |
42 | ||
c9164975 DM |
43 | # remove old APL dir |
44 | rm -rf /var/lib/pve-manager/apl-available | |
782bc232 | 45 | |
c9355915 WL |
46 | # remove old cron.daily update job to randomize it |
47 | if test -e /etc/cron.daily/pve; then | |
48 | echo "Remove old update script from cron.daily" | |
49 | rm /etc/cron.daily/pve | |
50 | fi | |
51 | ||
f13b9540 DM |
52 | # remove old/usused init.d files |
53 | rm -f /etc/init.d/pvebanner | |
54 | rm -f /etc/init.d/pvenetcommit | |
55 | ||
c9355915 | 56 | # create new daily randomize update cronjob if not exist |
8891d66f | 57 | MIN="$(shuf -i 0-59 -n 1)" |
e1f0dcce | 58 | HOUR="$(shuf -i 2-5 -n 1)" |
8891d66f DM |
59 | cat <<EOF >/etc/cron.d/pveupdate |
60 | # automatically generated - do not edit | |
61 | ${MIN} ${HOUR} * * * root /usr/bin/pveupdate | |
62 | EOF | |
c9355915 | 63 | |
75a6a7f5 DM |
64 | if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then |
65 | mkdir -p /var/lib/pve-manager/apl-info | |
66 | cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com | |
67 | pveam update || true | |
68 | fi | |
69 | ||
782bc232 DM |
70 | if test -f /root/.forward; then |
71 | if ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then | |
341e4b0b | 72 | echo -e "|/usr/bin/pvemailforward\n$(cat /root/.forward)" >/root/.forward.tmp |
782bc232 DM |
73 | mv /root/.forward.tmp /root/.forward |
74 | fi | |
75 | else | |
76 | echo '|/usr/bin/pvemailforward' >/root/.forward | |
77 | fi | |
d0e55a85 DM |
78 | |
79 | # disable fancy init messages (bad with bootlogd) | |
6675a064 DM |
80 | test -f /etc/lsb-base-logging.sh || echo "FANCYTTY=0" >/etc/lsb-base-logging.sh |
81 | ||
2bde88fb FG |
82 | if [ -f /etc/systemd/system/ceph.service ]; then |
83 | md5=$(md5sum /etc/systemd/system/ceph.service) | |
84 | if [[ "$md5" == "21b2e7a7c4ffcf92ad0ec2c905e88e5b /etc/systemd/system/ceph.service" ]]; then | |
85 | echo "Updating PVE ceph.service to correct install target.." | |
86 | cp /usr/share/doc/pve-manager/examples/ceph.service /etc/systemd/system/ceph.service | |
87 | systemctl --system daemon-reload >/dev/null || true | |
88 | systemctl --system disable ceph.service | |
89 | systemctl --system enable ceph.service | |
90 | echo " done" | |
91 | fi | |
92 | fi | |
6675a064 DM |
93 | |
94 | systemctl --system daemon-reload >/dev/null || true | |
95 | ||
96 | # same as dh_systemd_enable (code copied) | |
97 | ||
0dfd4a94 WL |
98 | for timer in pvesr; do |
99 | deb-systemd-helper unmask $timer.timer >/dev/null || true | |
100 | ||
101 | # was-enabled defaults to true, so new installations run enable. | |
102 | if deb-systemd-helper --quiet was-enabled $timer.timer; then | |
103 | # Enables the unit on first installation, creates new | |
104 | # symlinks on upgrades if the unit file has changed. | |
105 | deb-systemd-helper enable $timer.timer >/dev/null || true | |
106 | else | |
107 | # Update the statefile to add new symlinks (if any), which need to be | |
108 | # cleaned up on purge. Also remove old symlinks. | |
109 | deb-systemd-helper update-state $timer.timer >/dev/null || true | |
110 | fi | |
111 | done | |
112 | ||
6675a064 DM |
113 | for service in pvedaemon pveproxy spiceproxy pvestatd pvebanner pvenetcommit pve-manager; do |
114 | deb-systemd-helper unmask $service.service >/dev/null || true | |
115 | ||
116 | # was-enabled defaults to true, so new installations run enable. | |
117 | if deb-systemd-helper --quiet was-enabled $service.service; then | |
118 | # Enables the unit on first installation, creates new | |
119 | # symlinks on upgrades if the unit file has changed. | |
120 | deb-systemd-helper enable $service.service >/dev/null || true | |
121 | else | |
122 | # Update the statefile to add new symlinks (if any), which need to be | |
123 | # cleaned up on purge. Also remove old symlinks. | |
124 | deb-systemd-helper update-state $service.service >/dev/null || true | |
125 | fi | |
126 | done | |
127 | ||
128 | if test ! -e /proxmox_install_mode; then | |
129 | ||
130 | for service in pvedaemon pveproxy spiceproxy pvestatd; do | |
a55fbccc | 131 | deb-systemd-invoke reload-or-restart $service |
6675a064 | 132 | done |
0dfd4a94 WL |
133 | |
134 | deb-systemd-invoke start pvesr.timer >/dev/null || true | |
6675a064 | 135 | fi |
12fe9183 DM |
136 | |
137 | # enable startcom-ca2.crt for enterprise repository | |
138 | update-ca-certificates >/dev/null 2>&1 | |
139 | ||
ad2c9763 | 140 | # rewrite banner |
6675a064 | 141 | test -e /proxmox_install_mode || pvebanner || true |
aff192e6 | 142 | |
0c308a03 | 143 | #a2ensite pve.conf >/dev/null 2>&1 |
aff192e6 DM |
144 | |
145 | # There are three sub-cases: | |
146 | if test "${2+set}" != set; then | |
147 | # We're being installed by an ancient dpkg which doesn't remember | |
148 | # which version was most recently configured, or even whether | |
149 | # there is a most recently configured version. | |
150 | : | |
151 | ||
152 | elif test -z "$2" -o "$2" = "<unknown>"; then | |
153 | # The package has not ever been configured on this system, or was | |
154 | # purged since it was last configured. | |
155 | : | |
156 | ||
157 | else | |
158 | # Version $2 is the most recently configured version of this | |
159 | # package. | |
160 | : | |
161 | ||
162 | fi ;; | |
163 | abort-upgrade) | |
164 | # Back out of an attempt to upgrade this package FROM THIS VERSION | |
165 | # to version $2. Undo the effects of "prerm upgrade $2". | |
166 | : | |
167 | ||
168 | ;; | |
169 | abort-remove) | |
170 | if test "$2" != in-favour; then | |
171 | echo "$0: undocumented call to \`postinst $*'" 1>&2 | |
172 | exit 0 | |
173 | fi | |
174 | # Back out of an attempt to remove this package, which was due to | |
175 | # a conflict with package $3 (version $4). Undo the effects of | |
176 | # "prerm remove in-favour $3 $4". | |
177 | : | |
178 | ||
179 | ;; | |
180 | abort-deconfigure) | |
181 | if test "$2" != in-favour -o "$5" != removing; then | |
182 | echo "$0: undocumented call to \`postinst $*'" 1>&2 | |
183 | exit 0 | |
184 | fi | |
185 | # Back out of an attempt to deconfigure this package, which was | |
186 | # due to package $6 (version $7) which we depend on being removed | |
187 | # to make way for package $3 (version $4). Undo the effects of | |
188 | # "prerm deconfigure in-favour $3 $4 removing $6 $7". | |
189 | : | |
190 | ||
191 | ;; | |
192 | *) echo "$0: didn't understand being called with \`$1'" 1>&2 | |
193 | exit 0;; | |
194 | esac | |
195 | ||
196 | exit 0 |