]>
Commit | Line | Data |
---|---|---|
28e6daaa | 1 | #!/bin/sh |
aff192e6 | 2 | |
60b5e2d8 | 3 | # Abort if any command returns an error value |
aff192e6 DM |
4 | set -e |
5 | ||
60b5e2d8 TL |
6 | # This script is called as the last step of the installation of the package. |
7 | # All the package's files are in place, dpkg has already done its automatic | |
8 | # conffile handling, and all the packages we depend of are already fully | |
9 | # installed and configured. | |
aff192e6 | 10 | |
c6908859 FG |
11 | set_lvm_conf() { |
12 | LVM_CONF_MARKER="# added by pve-manager to avoid scanning" | |
13 | ||
14 | # only do these changes once | |
15 | # keep user changes afterwards provided marker is still there.. | |
16 | if ! grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then | |
60b5e2d8 TL |
17 | OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)" |
18 | NEW_VALUE='global_filter=["r|/dev/zd.*|"]' | |
19 | ||
20 | export LVM_SUPPRESS_FD_WARNINGS=1 | |
21 | ||
22 | # check global_filter | |
23 | # keep previous setting from our custom packaging if it is still there | |
24 | if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then | |
25 | SET_FILTER=1 | |
26 | BACKUP=1 | |
27 | fi | |
28 | # should be the default since bullseye | |
29 | if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then | |
30 | SET_SCAN_LVS=1 | |
31 | BACKUP=1 | |
32 | fi | |
33 | if test -n "$BACKUP"; then | |
34 | echo "Backing up lvm.conf before setting pve-manager specific settings.." | |
35 | cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak | |
36 | fi | |
37 | if test -n "$SET_FILTER"; then | |
38 | echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:" | |
39 | echo "$OLD_VALUE => $NEW_VALUE" | |
40 | # comment out existing setting | |
41 | sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf | |
42 | # add new section with our setting | |
43 | cat >> /etc/lvm/lvm.conf <<EOF | |
c6908859 | 44 | devices { |
60b5e2d8 TL |
45 | $LVM_CONF_MARKER ZFS zvols |
46 | $NEW_VALUE | |
47 | } | |
c6908859 | 48 | EOF |
60b5e2d8 TL |
49 | fi |
50 | if test -n "$SET_SCAN_LVS"; then | |
51 | echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned." | |
52 | # comment out existing setting | |
53 | sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf | |
54 | # add new section with our setting | |
55 | cat >> /etc/lvm/lvm.conf <<EOF | |
c6908859 | 56 | devices { |
60b5e2d8 TL |
57 | $LVM_CONF_MARKER LVM volumes |
58 | scan_lvs=0 | |
59 | } | |
c6908859 | 60 | EOF |
60b5e2d8 | 61 | fi |
c6908859 FG |
62 | fi |
63 | } | |
64 | ||
bf09acfe FG |
65 | migrate_apt_auth_conf() { |
66 | output="" | |
67 | removed="" | |
68 | match=0 | |
69 | ||
70 | while read -r l; do | |
60b5e2d8 TL |
71 | if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then |
72 | match=1 | |
73 | elif echo "$l" | grep -q "machine"; then | |
74 | match=0 | |
75 | fi | |
76 | ||
77 | if test "$match" = "1"; then | |
78 | removed="$removed\n$l" | |
79 | else | |
80 | output="$output\n$l" | |
81 | fi | |
bf09acfe FG |
82 | done < /etc/apt/auth.conf |
83 | ||
84 | if test -n "$removed"; then | |
60b5e2d8 TL |
85 | if test ! -e /etc/apt/auth.conf.d/pve.conf; then |
86 | echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .." | |
87 | echo "$removed" > /etc/apt/auth.conf.d/pve.conf | |
88 | else | |
89 | echo "Removing stale APT auth config from /etc/apt/auth.conf" | |
90 | fi | |
91 | echo "$output" > /etc/apt/auth.conf | |
bf09acfe FG |
92 | fi |
93 | } | |
94 | ||
aff192e6 DM |
95 | case "$1" in |
96 | triggered) | |
97 | # We don't print a status message here, as dpkg already said | |
98 | # "Processing triggers for ...". | |
99 | ||
099e5477 DM |
100 | # test if /etc/pve is mounted; else simple exit to avoid |
101 | # error during updates | |
102 | test -f /etc/pve/local/pve-ssl.pem || exit 0; | |
6675a064 | 103 | test -e /proxmox_install_mode && exit 0; |
81019d9d | 104 | |
ea067f42 | 105 | # the ExecStartPre doesn't triggers on service reload, so just in case |
9efc89f6 | 106 | pvecm updatecerts --silent || true |
ea067f42 | 107 | |
15c72102 FG |
108 | deb-systemd-invoke reload-or-try-restart pvedaemon.service |
109 | deb-systemd-invoke reload-or-try-restart pvestatd.service | |
110 | deb-systemd-invoke reload-or-try-restart pveproxy.service | |
111 | deb-systemd-invoke reload-or-try-restart spiceproxy.service | |
6385fb81 | 112 | deb-systemd-invoke reload-or-try-restart pvescheduler.service |
aff192e6 DM |
113 | |
114 | exit 0;; | |
115 | ||
116 | configure) | |
117 | # Configure this package. If the package must prompt the user for | |
118 | # information, do it here. | |
119 | ||
120 | mkdir /etc/pve 2>/dev/null || true | |
121 | ||
75a6a7f5 | 122 | if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then |
60b5e2d8 TL |
123 | mkdir -p /var/lib/pve-manager/apl-info |
124 | cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com | |
125 | pveam update || true | |
75a6a7f5 DM |
126 | fi |
127 | ||
544221fa | 128 | if ! test -f /root/.forward || ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then |
60b5e2d8 | 129 | echo '|/usr/bin/pvemailforward' >>/root/.forward |
782bc232 | 130 | fi |
d0e55a85 | 131 | |
6675a064 DM |
132 | systemctl --system daemon-reload >/dev/null || true |
133 | ||
134 | # same as dh_systemd_enable (code copied) | |
135 | ||
6385fb81 | 136 | UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer" |
aad80361 | 137 | NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" |
0dfd4a94 | 138 | |
aad80361 | 139 | for unit in ${UNITS} ${NO_RESTART_UNITS}; do |
60b5e2d8 TL |
140 | deb-systemd-helper unmask "$unit" >/dev/null || true |
141 | ||
142 | # was-enabled defaults to true, so new installations run enable. | |
143 | if deb-systemd-helper --quiet was-enabled "$unit"; then | |
144 | # Enables the unit on first installation, creates new | |
145 | # symlinks on upgrades if the unit file has changed. | |
146 | deb-systemd-helper enable "$unit" >/dev/null || true | |
147 | else | |
148 | # Update the statefile to add new symlinks (if any), which need to be | |
149 | # cleaned up on purge. Also remove old symlinks. | |
150 | deb-systemd-helper update-state "$unit" >/dev/null || true | |
151 | fi | |
6675a064 DM |
152 | done |
153 | ||
6e3ca3d3 TL |
154 | # FIXME: remove after beta is over and add hunk to actively remove the repo |
155 | BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list" | |
e8fed6b6 | 156 | if test -f "$BETA_SOURCES" && dpkg --compare-versions "$2" 'lt' '7.0-9~' && dpkg --compare-versions "$2" 'gt' '7.0~'; then |
60b5e2d8 TL |
157 | echo "Removing the during beta added pvetest repository file again" |
158 | rm -v "$BETA_SOURCES" || true | |
6e3ca3d3 TL |
159 | fi |
160 | ||
891ea8e8 | 161 | # FIXME: remove in PVE 8.0 |
4c5bb367 | 162 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.0-6~'; then |
60b5e2d8 TL |
163 | # PVE 4.0 beta to 5.4 ISO had a bug and did not generated a unique machine-id. below is a |
164 | # very relaxed machine-id list from all ISOs (released, tests & internal) possibly affected | |
165 | if grep -q \ | |
166 | -e a0ee88c29b764c46a579dd89c86c2d84 \ | |
167 | -e ecbf104295bd4f8b90bb82dc2fa5e9e5 \ | |
168 | -e c8fa51cd0c254ea08b0e37c1e37afbb9 \ | |
169 | -e 2ec24eda629a4c8d8c1f8dac50a9ee5f \ | |
170 | -e ef8db290720047159b426bd322839d70 \ | |
171 | -e bd94244c0da6419a82a383e62dc03b51 \ | |
172 | -e 45d4e7046c3d4c26af8acd589f358ac6 \ | |
173 | -e 8c445f96b3064ff79f825ea78a3eefde \ | |
174 | -e 6f9fae0f0a794fd4b89b3abecfd7f182 \ | |
175 | -e 6f9fae0f0a794fd4b89b3abecfd7f182 \ | |
176 | -e 285de85759894b3f9ad9844a89045af6 \ | |
177 | -e 89971dede7b04c98b2b0bc8845f53320 \ | |
178 | -e 4e3b6e9550f24d638bc26211a7b37df5 \ | |
179 | -e bc2f684e31ee4daf95e45c62410a95b1 \ | |
180 | -e 8cc7bc883fd048b78a4af7433c48e341 \ | |
181 | -e 9b46d99712854566bb02a656a3ff9191 \ | |
182 | -e e7fc055af47048ee884dcb88a7474336 \ | |
183 | -e 13d879f75e6447a69ed85179bd93759a \ | |
184 | -e 5b59e448c3e74029af2ac91f572d68a7 \ | |
185 | -e 5a2bd0d11a6c41f9a33fd527751224ea \ | |
186 | -e 516afc72013c4b9da85b309aad987df2 \ | |
187 | -e b0ce8d24684845e8ac337c588a7715cb \ | |
188 | -e e0af064c16e9463e9fa980eac66427c1 \ | |
189 | -e 6e925d11b497446e8e7f2ff38e7cf891 \ | |
190 | -e eec280213051474d8bfe7e089a86744a \ | |
191 | -e 708ded6ee82a46c08b77fecda2284c6c \ | |
192 | -e 615cb2b78b2240289fef74da610c146f \ | |
193 | -e b965b329a7e246d5be66a8d367f5760d \ | |
194 | -e 5472a49c6436426fbebd7881f7b7f13b \ | |
195 | /etc/machine-id | |
196 | then | |
197 | echo "found static machine-id bug from Proxmox VE ISO installer <= 5.4, regenerating machine-id" | |
198 | systemd-id128 new | tee /etc/machine-id.new /var/lib/dbus/machine-id.new | |
199 | # atomically replace | |
200 | mv /etc/machine-id.new /etc/machine-id | |
201 | mv /var/lib/dbus/machine-id.new /var/lib/dbus/machine-id | |
202 | echo "new machine-id generated, a reboot is recommended" | |
203 | else | |
204 | echo "machine-id check OK" | |
205 | fi | |
5fb7a28a TL |
206 | fi |
207 | ||
c6908859 FG |
208 | set_lvm_conf |
209 | ||
6675a064 | 210 | if test ! -e /proxmox_install_mode; then |
60b5e2d8 TL |
211 | # modeled after code generated by dh_start |
212 | for unit in ${UNITS}; do | |
213 | if test -n "$2"; then | |
214 | dh_action="reload-or-restart"; | |
215 | else | |
216 | dh_action="start" | |
217 | fi | |
218 | if systemctl -q is-enabled "$unit"; then | |
219 | deb-systemd-invoke $dh_action "$unit" | |
220 | fi | |
221 | done | |
6675a064 | 222 | fi |
bf09acfe FG |
223 | |
224 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2.11~'; then | |
60b5e2d8 TL |
225 | if test -e /etc/apt/auth.conf ; then |
226 | migrate_apt_auth_conf | |
227 | fi | |
bf09acfe | 228 | fi |
01fe34e0 | 229 | ;; |
aff192e6 | 230 | |
e3ffd2c0 | 231 | abort-upgrade|abort-remove|abort-deconfigure) |
aff192e6 | 232 | ;; |
aff192e6 | 233 | |
aff192e6 DM |
234 | *) echo "$0: didn't understand being called with \`$1'" 1>&2 |
235 | exit 0;; | |
236 | esac | |
237 | ||
238 | exit 0 |