]>
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 | ||
bf09acfe FG |
83 | migrate_apt_auth_conf() { |
84 | output="" | |
85 | removed="" | |
86 | match=0 | |
87 | ||
88 | while read -r l; do | |
60b5e2d8 TL |
89 | if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then |
90 | match=1 | |
91 | elif echo "$l" | grep -q "machine"; then | |
92 | match=0 | |
93 | fi | |
94 | ||
95 | if test "$match" = "1"; then | |
96 | removed="$removed\n$l" | |
97 | else | |
98 | output="$output\n$l" | |
99 | fi | |
bf09acfe FG |
100 | done < /etc/apt/auth.conf |
101 | ||
102 | if test -n "$removed"; then | |
60b5e2d8 TL |
103 | if test ! -e /etc/apt/auth.conf.d/pve.conf; then |
104 | echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .." | |
105 | echo "$removed" > /etc/apt/auth.conf.d/pve.conf | |
106 | else | |
107 | echo "Removing stale APT auth config from /etc/apt/auth.conf" | |
108 | fi | |
109 | echo "$output" > /etc/apt/auth.conf | |
bf09acfe FG |
110 | fi |
111 | } | |
112 | ||
aff192e6 DM |
113 | case "$1" in |
114 | triggered) | |
115 | # We don't print a status message here, as dpkg already said | |
116 | # "Processing triggers for ...". | |
117 | ||
099e5477 DM |
118 | # test if /etc/pve is mounted; else simple exit to avoid |
119 | # error during updates | |
120 | test -f /etc/pve/local/pve-ssl.pem || exit 0; | |
6675a064 | 121 | test -e /proxmox_install_mode && exit 0; |
81019d9d | 122 | |
ea067f42 | 123 | # the ExecStartPre doesn't triggers on service reload, so just in case |
9efc89f6 | 124 | pvecm updatecerts --silent || true |
ea067f42 | 125 | |
15c72102 FG |
126 | deb-systemd-invoke reload-or-try-restart pvedaemon.service |
127 | deb-systemd-invoke reload-or-try-restart pvestatd.service | |
128 | deb-systemd-invoke reload-or-try-restart pveproxy.service | |
129 | deb-systemd-invoke reload-or-try-restart spiceproxy.service | |
6385fb81 | 130 | deb-systemd-invoke reload-or-try-restart pvescheduler.service |
aff192e6 DM |
131 | |
132 | exit 0;; | |
133 | ||
134 | configure) | |
135 | # Configure this package. If the package must prompt the user for | |
136 | # information, do it here. | |
137 | ||
138 | mkdir /etc/pve 2>/dev/null || true | |
139 | ||
75a6a7f5 | 140 | if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then |
60b5e2d8 TL |
141 | mkdir -p /var/lib/pve-manager/apl-info |
142 | cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com | |
143 | pveam update || true | |
75a6a7f5 DM |
144 | fi |
145 | ||
b632562c FE |
146 | # Always try to clean old entry, even when proxmox-mail-forward entry is already present. |
147 | # This ensures it will still be cleaned after an upgrade following a downgrade. | |
148 | if test -f /root/.forward; then | |
149 | sed -i '\!|/usr/bin/pvemailforward!d' /root/.forward | |
150 | fi | |
151 | ||
152 | if ! test -f /root/.forward || ! grep -q '|/usr/bin/proxmox-mail-forward' /root/.forward; then | |
153 | echo '|/usr/bin/proxmox-mail-forward' >>/root/.forward | |
782bc232 | 154 | fi |
d0e55a85 | 155 | |
6675a064 DM |
156 | systemctl --system daemon-reload >/dev/null || true |
157 | ||
158 | # same as dh_systemd_enable (code copied) | |
159 | ||
6385fb81 | 160 | UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer" |
aad80361 | 161 | NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" |
0dfd4a94 | 162 | |
aad80361 | 163 | for unit in ${UNITS} ${NO_RESTART_UNITS}; do |
60b5e2d8 TL |
164 | deb-systemd-helper unmask "$unit" >/dev/null || true |
165 | ||
166 | # was-enabled defaults to true, so new installations run enable. | |
167 | if deb-systemd-helper --quiet was-enabled "$unit"; then | |
168 | # Enables the unit on first installation, creates new | |
169 | # symlinks on upgrades if the unit file has changed. | |
170 | deb-systemd-helper enable "$unit" >/dev/null || true | |
171 | else | |
172 | # Update the statefile to add new symlinks (if any), which need to be | |
173 | # cleaned up on purge. Also remove old symlinks. | |
174 | deb-systemd-helper update-state "$unit" >/dev/null || true | |
175 | fi | |
6675a064 DM |
176 | done |
177 | ||
6e3ca3d3 TL |
178 | # FIXME: remove after beta is over and add hunk to actively remove the repo |
179 | BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list" | |
2f11eee5 | 180 | if test -f "$BETA_SOURCES" && dpkg --compare-versions "$2" 'lt' '8.0.2' && dpkg --compare-versions "$2" 'gt' '8.0~'; then |
575a0e8a DC |
181 | echo "Removing the during beta added pvetest repository file again" |
182 | rm -v "$BETA_SOURCES" || true | |
6e3ca3d3 TL |
183 | fi |
184 | ||
250d7b07 SH |
185 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '8.1.4~'; then |
186 | if test -e /etc/lvm/lvm.conf ; then | |
187 | set_lvm_conf 1 | |
188 | fi | |
189 | fi | |
190 | ||
c6908859 FG |
191 | set_lvm_conf |
192 | ||
6675a064 | 193 | if test ! -e /proxmox_install_mode; then |
60b5e2d8 TL |
194 | # modeled after code generated by dh_start |
195 | for unit in ${UNITS}; do | |
196 | if test -n "$2"; then | |
197 | dh_action="reload-or-restart"; | |
198 | else | |
199 | dh_action="start" | |
200 | fi | |
201 | if systemctl -q is-enabled "$unit"; then | |
202 | deb-systemd-invoke $dh_action "$unit" | |
203 | fi | |
204 | done | |
6675a064 | 205 | fi |
bf09acfe | 206 | |
4209cc3a | 207 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2-11~'; then |
60b5e2d8 TL |
208 | if test -e /etc/apt/auth.conf ; then |
209 | migrate_apt_auth_conf | |
210 | fi | |
bf09acfe | 211 | fi |
01fe34e0 | 212 | ;; |
aff192e6 | 213 | |
e3ffd2c0 | 214 | abort-upgrade|abort-remove|abort-deconfigure) |
aff192e6 | 215 | ;; |
aff192e6 | 216 | |
aff192e6 DM |
217 | *) echo "$0: didn't understand being called with \`$1'" 1>&2 |
218 | exit 0;; | |
219 | esac | |
220 | ||
221 | exit 0 |