]>
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 | 11 | set_lvm_conf() { |
250d7b07 | 12 | local FORCE="$1" |
c6908859 FG |
13 | LVM_CONF_MARKER="# added by pve-manager to avoid scanning" |
14 | ||
c6908859 | 15 | # keep user changes afterwards provided marker is still there.. |
250d7b07 | 16 | if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf && test -z "$FORCE"; then |
2833e1e1 TL |
17 | return 0 # only do these changes once |
18 | fi | |
60b5e2d8 | 19 | |
2833e1e1 TL |
20 | export LVM_SUPPRESS_FD_WARNINGS=1 |
21 | ||
250d7b07 SH |
22 | OLD_VALUE="$(lvmconfig --typeconfig diff devices/global_filter || true)" |
23 | NEW_VALUE='global_filter=["r|/dev/zd.*|","r|/dev/rbd.*|"]' | |
24 | ||
25 | # update global_filter if: | |
26 | # it is empty and there is no marker OR exactly the one we set before 8.1.4 | |
27 | if (! grep -qF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf && test -z "$OLD_VALUE")\ | |
395dbe6b | 28 | || (echo "$OLD_VALUE" | grep -qF '="r|/dev/zd.*|"'); |
250d7b07 | 29 | then |
2833e1e1 TL |
30 | SET_FILTER=1 |
31 | BACKUP=1 | |
250d7b07 SH |
32 | # print warning if global_filter is set but not our old/new default |
33 | elif test -n "$OLD_VALUE"\ | |
395dbe6b TL |
34 | && ! echo "$OLD_VALUE" | grep -qF '="r|/dev/zd.*|"'\ |
35 | && ! echo "$OLD_VALUE" | grep -qF "$NEW_VALUE"; | |
250d7b07 | 36 | then |
395dbe6b TL |
37 | echo "non-default 'global_filter' value '$OLD_VALUE' in /etc/lvm/lvm.conf, not setting '$NEW_VALUE' automatically" |
38 | echo "consider adapting your 'global_filter' manually." | |
2833e1e1 TL |
39 | fi |
40 | # should be the default since bullseye | |
41 | if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then | |
42 | SET_SCAN_LVS=1 | |
43 | BACKUP=1 | |
44 | fi | |
45 | if test -n "$BACKUP"; then | |
46 | echo "Backing up lvm.conf before setting pve-manager specific settings.." | |
47 | cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak | |
48 | fi | |
49 | if test -n "$SET_FILTER"; then | |
250d7b07 | 50 | echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols and rbds from being scanned:" |
2833e1e1 | 51 | echo "$OLD_VALUE => $NEW_VALUE" |
250d7b07 SH |
52 | if test -n "$OLD_VALUE"; then |
53 | sed -i -e "s/$LVM_CONF_MARKER ZFS zvols/$LVM_CONF_MARKER ZFS zvols and Ceph rbds/" /etc/lvm/lvm.conf | |
54 | sed -i -e "s!^\([[:space:]]*\)\(global_filter[[:space:]]*=.*\)\$!\1# \2\n\1$NEW_VALUE!" /etc/lvm/lvm.conf | |
55 | else | |
56 | cat >> /etc/lvm/lvm.conf <<EOF | |
c6908859 | 57 | devices { |
250d7b07 | 58 | $LVM_CONF_MARKER ZFS zvols and Ceph rbds |
60b5e2d8 | 59 | $NEW_VALUE |
250d7b07 | 60 | } |
c6908859 | 61 | EOF |
250d7b07 | 62 | fi |
2833e1e1 TL |
63 | fi |
64 | if test -n "$SET_SCAN_LVS"; then | |
65 | echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned." | |
66 | # comment out existing setting | |
67 | sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf | |
68 | # add new section with our setting | |
69 | cat >> /etc/lvm/lvm.conf <<EOF | |
c6908859 | 70 | devices { |
60b5e2d8 TL |
71 | $LVM_CONF_MARKER LVM volumes |
72 | scan_lvs=0 | |
73 | } | |
c6908859 | 74 | EOF |
c6908859 | 75 | fi |
250d7b07 SH |
76 | |
77 | if ! lvmconfig --validate; then | |
395dbe6b TL |
78 | echo "Invalid LVM config detected - restoring from /etc/lvm/lvm.conf.bak" |
79 | mv /etc/lvm/lvm.conf.bak /etc/lvm/lvm.conf | |
250d7b07 | 80 | fi |
c6908859 FG |
81 | } |
82 | ||
a51a28e3 | 83 | update_ceph_conf() { |
11edd5d8 MC |
84 | UNIT='ceph-crash.service' |
85 | ||
11edd5d8 MC |
86 | # Don't fail in case user has "exotic" configuration where RADOS |
87 | # isn't available on all nodes for some reason | |
88 | /usr/share/pve-manager/helpers/pve-init-ceph-crash || true | |
89 | ||
90 | if systemctl -q is-enabled "$UNIT" 2> /dev/null; then | |
91 | deb-systemd-invoke restart "$UNIT" || true | |
92 | fi | |
a51a28e3 MC |
93 | } |
94 | ||
bf09acfe FG |
95 | migrate_apt_auth_conf() { |
96 | output="" | |
97 | removed="" | |
98 | match=0 | |
99 | ||
100 | while read -r l; do | |
60b5e2d8 TL |
101 | if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then |
102 | match=1 | |
103 | elif echo "$l" | grep -q "machine"; then | |
104 | match=0 | |
105 | fi | |
106 | ||
107 | if test "$match" = "1"; then | |
108 | removed="$removed\n$l" | |
109 | else | |
110 | output="$output\n$l" | |
111 | fi | |
bf09acfe FG |
112 | done < /etc/apt/auth.conf |
113 | ||
114 | if test -n "$removed"; then | |
60b5e2d8 TL |
115 | if test ! -e /etc/apt/auth.conf.d/pve.conf; then |
116 | echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .." | |
117 | echo "$removed" > /etc/apt/auth.conf.d/pve.conf | |
118 | else | |
119 | echo "Removing stale APT auth config from /etc/apt/auth.conf" | |
120 | fi | |
121 | echo "$output" > /etc/apt/auth.conf | |
bf09acfe FG |
122 | fi |
123 | } | |
124 | ||
aff192e6 DM |
125 | case "$1" in |
126 | triggered) | |
127 | # We don't print a status message here, as dpkg already said | |
128 | # "Processing triggers for ...". | |
129 | ||
099e5477 DM |
130 | # test if /etc/pve is mounted; else simple exit to avoid |
131 | # error during updates | |
132 | test -f /etc/pve/local/pve-ssl.pem || exit 0; | |
6675a064 | 133 | test -e /proxmox_install_mode && exit 0; |
81019d9d | 134 | |
ea067f42 | 135 | # the ExecStartPre doesn't triggers on service reload, so just in case |
9efc89f6 | 136 | pvecm updatecerts --silent || true |
ea067f42 | 137 | |
8d477326 FG |
138 | deb-systemd-invoke reload-or-try-restart pvedaemon.service || true |
139 | deb-systemd-invoke reload-or-try-restart pvestatd.service || true | |
140 | deb-systemd-invoke reload-or-try-restart pveproxy.service || true | |
141 | deb-systemd-invoke reload-or-try-restart spiceproxy.service || true | |
142 | deb-systemd-invoke reload-or-try-restart pvescheduler.service || true | |
aff192e6 DM |
143 | |
144 | exit 0;; | |
145 | ||
146 | configure) | |
147 | # Configure this package. If the package must prompt the user for | |
148 | # information, do it here. | |
149 | ||
150 | mkdir /etc/pve 2>/dev/null || true | |
151 | ||
75a6a7f5 | 152 | if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then |
60b5e2d8 TL |
153 | mkdir -p /var/lib/pve-manager/apl-info |
154 | cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com | |
155 | pveam update || true | |
75a6a7f5 DM |
156 | fi |
157 | ||
b632562c FE |
158 | # Always try to clean old entry, even when proxmox-mail-forward entry is already present. |
159 | # This ensures it will still be cleaned after an upgrade following a downgrade. | |
160 | if test -f /root/.forward; then | |
161 | sed -i '\!|/usr/bin/pvemailforward!d' /root/.forward | |
162 | fi | |
163 | ||
164 | if ! test -f /root/.forward || ! grep -q '|/usr/bin/proxmox-mail-forward' /root/.forward; then | |
165 | echo '|/usr/bin/proxmox-mail-forward' >>/root/.forward | |
782bc232 | 166 | fi |
d0e55a85 | 167 | |
6675a064 DM |
168 | systemctl --system daemon-reload >/dev/null || true |
169 | ||
170 | # same as dh_systemd_enable (code copied) | |
171 | ||
6385fb81 | 172 | UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer" |
aad80361 | 173 | NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" |
0dfd4a94 | 174 | |
aad80361 | 175 | for unit in ${UNITS} ${NO_RESTART_UNITS}; do |
60b5e2d8 TL |
176 | deb-systemd-helper unmask "$unit" >/dev/null || true |
177 | ||
178 | # was-enabled defaults to true, so new installations run enable. | |
179 | if deb-systemd-helper --quiet was-enabled "$unit"; then | |
180 | # Enables the unit on first installation, creates new | |
181 | # symlinks on upgrades if the unit file has changed. | |
182 | deb-systemd-helper enable "$unit" >/dev/null || true | |
183 | else | |
184 | # Update the statefile to add new symlinks (if any), which need to be | |
185 | # cleaned up on purge. Also remove old symlinks. | |
186 | deb-systemd-helper update-state "$unit" >/dev/null || true | |
187 | fi | |
6675a064 DM |
188 | done |
189 | ||
6e3ca3d3 TL |
190 | # FIXME: remove after beta is over and add hunk to actively remove the repo |
191 | BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list" | |
2f11eee5 | 192 | if test -f "$BETA_SOURCES" && dpkg --compare-versions "$2" 'lt' '8.0.2' && dpkg --compare-versions "$2" 'gt' '8.0~'; then |
575a0e8a DC |
193 | echo "Removing the during beta added pvetest repository file again" |
194 | rm -v "$BETA_SOURCES" || true | |
6e3ca3d3 TL |
195 | fi |
196 | ||
250d7b07 SH |
197 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '8.1.4~'; then |
198 | if test -e /etc/lvm/lvm.conf ; then | |
199 | set_lvm_conf 1 | |
200 | fi | |
201 | fi | |
202 | ||
c6908859 FG |
203 | set_lvm_conf |
204 | ||
2ff48ca7 | 205 | if test -n "$2" && dpkg --compare-versions "$2" 'lt' '8.1.11'; then |
a51a28e3 MC |
206 | update_ceph_conf |
207 | fi | |
208 | ||
6675a064 | 209 | if test ! -e /proxmox_install_mode; then |
60b5e2d8 TL |
210 | # modeled after code generated by dh_start |
211 | for unit in ${UNITS}; do | |
212 | if test -n "$2"; then | |
213 | dh_action="reload-or-restart"; | |
214 | else | |
215 | dh_action="start" | |
216 | fi | |
217 | if systemctl -q is-enabled "$unit"; then | |
8d477326 | 218 | deb-systemd-invoke $dh_action "$unit" || true |
60b5e2d8 TL |
219 | fi |
220 | done | |
6675a064 | 221 | fi |
bf09acfe | 222 | |
4209cc3a | 223 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2-11~'; then |
60b5e2d8 TL |
224 | if test -e /etc/apt/auth.conf ; then |
225 | migrate_apt_auth_conf | |
226 | fi | |
bf09acfe | 227 | fi |
01fe34e0 | 228 | ;; |
aff192e6 | 229 | |
e3ffd2c0 | 230 | abort-upgrade|abort-remove|abort-deconfigure) |
aff192e6 | 231 | ;; |
aff192e6 | 232 | |
aff192e6 DM |
233 | *) echo "$0: didn't understand being called with \`$1'" 1>&2 |
234 | exit 0;; | |
235 | esac | |
236 | ||
237 | exit 0 |