]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
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 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. | |
10 | ||
11 | set_lvm_conf() { | |
12 | LVM_CONF_MARKER="# added by pve-manager to avoid scanning" | |
13 | ||
14 | # keep user changes afterwards provided marker is still there.. | |
15 | if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then | |
16 | return 0 # only do these changes once | |
17 | fi | |
18 | ||
19 | OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)" | |
20 | NEW_VALUE='global_filter=["r|/dev/zd.*|"]' | |
21 | ||
22 | export LVM_SUPPRESS_FD_WARNINGS=1 | |
23 | ||
24 | # check global_filter | |
25 | # keep previous setting from our custom packaging if it is still there | |
26 | if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then | |
27 | SET_FILTER=1 | |
28 | BACKUP=1 | |
29 | fi | |
30 | # should be the default since bullseye | |
31 | if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then | |
32 | SET_SCAN_LVS=1 | |
33 | BACKUP=1 | |
34 | fi | |
35 | if test -n "$BACKUP"; then | |
36 | echo "Backing up lvm.conf before setting pve-manager specific settings.." | |
37 | cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak | |
38 | fi | |
39 | if test -n "$SET_FILTER"; then | |
40 | echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:" | |
41 | echo "$OLD_VALUE => $NEW_VALUE" | |
42 | # comment out existing setting | |
43 | sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf | |
44 | # add new section with our setting | |
45 | cat >> /etc/lvm/lvm.conf <<EOF | |
46 | devices { | |
47 | $LVM_CONF_MARKER ZFS zvols | |
48 | $NEW_VALUE | |
49 | } | |
50 | EOF | |
51 | fi | |
52 | if test -n "$SET_SCAN_LVS"; then | |
53 | echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned." | |
54 | # comment out existing setting | |
55 | sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf | |
56 | # add new section with our setting | |
57 | cat >> /etc/lvm/lvm.conf <<EOF | |
58 | devices { | |
59 | $LVM_CONF_MARKER LVM volumes | |
60 | scan_lvs=0 | |
61 | } | |
62 | EOF | |
63 | fi | |
64 | } | |
65 | ||
66 | migrate_apt_auth_conf() { | |
67 | output="" | |
68 | removed="" | |
69 | match=0 | |
70 | ||
71 | while read -r l; do | |
72 | if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pve"; then | |
73 | match=1 | |
74 | elif echo "$l" | grep -q "machine"; then | |
75 | match=0 | |
76 | fi | |
77 | ||
78 | if test "$match" = "1"; then | |
79 | removed="$removed\n$l" | |
80 | else | |
81 | output="$output\n$l" | |
82 | fi | |
83 | done < /etc/apt/auth.conf | |
84 | ||
85 | if test -n "$removed"; then | |
86 | if test ! -e /etc/apt/auth.conf.d/pve.conf; then | |
87 | echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pve.conf .." | |
88 | echo "$removed" > /etc/apt/auth.conf.d/pve.conf | |
89 | else | |
90 | echo "Removing stale APT auth config from /etc/apt/auth.conf" | |
91 | fi | |
92 | echo "$output" > /etc/apt/auth.conf | |
93 | fi | |
94 | } | |
95 | ||
96 | case "$1" in | |
97 | triggered) | |
98 | # We don't print a status message here, as dpkg already said | |
99 | # "Processing triggers for ...". | |
100 | ||
101 | # test if /etc/pve is mounted; else simple exit to avoid | |
102 | # error during updates | |
103 | test -f /etc/pve/local/pve-ssl.pem || exit 0; | |
104 | test -e /proxmox_install_mode && exit 0; | |
105 | ||
106 | # the ExecStartPre doesn't triggers on service reload, so just in case | |
107 | pvecm updatecerts --silent || true | |
108 | ||
109 | deb-systemd-invoke reload-or-try-restart pvedaemon.service | |
110 | deb-systemd-invoke reload-or-try-restart pvestatd.service | |
111 | deb-systemd-invoke reload-or-try-restart pveproxy.service | |
112 | deb-systemd-invoke reload-or-try-restart spiceproxy.service | |
113 | deb-systemd-invoke reload-or-try-restart pvescheduler.service | |
114 | ||
115 | exit 0;; | |
116 | ||
117 | configure) | |
118 | # Configure this package. If the package must prompt the user for | |
119 | # information, do it here. | |
120 | ||
121 | mkdir /etc/pve 2>/dev/null || true | |
122 | ||
123 | if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then | |
124 | mkdir -p /var/lib/pve-manager/apl-info | |
125 | cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com | |
126 | pveam update || true | |
127 | fi | |
128 | ||
129 | # Always try to clean old entry, even when proxmox-mail-forward entry is already present. | |
130 | # This ensures it will still be cleaned after an upgrade following a downgrade. | |
131 | if test -f /root/.forward; then | |
132 | sed -i '\!|/usr/bin/pvemailforward!d' /root/.forward | |
133 | fi | |
134 | ||
135 | if ! test -f /root/.forward || ! grep -q '|/usr/bin/proxmox-mail-forward' /root/.forward; then | |
136 | echo '|/usr/bin/proxmox-mail-forward' >>/root/.forward | |
137 | fi | |
138 | ||
139 | systemctl --system daemon-reload >/dev/null || true | |
140 | ||
141 | # same as dh_systemd_enable (code copied) | |
142 | ||
143 | UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer" | |
144 | NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" | |
145 | ||
146 | for unit in ${UNITS} ${NO_RESTART_UNITS}; do | |
147 | deb-systemd-helper unmask "$unit" >/dev/null || true | |
148 | ||
149 | # was-enabled defaults to true, so new installations run enable. | |
150 | if deb-systemd-helper --quiet was-enabled "$unit"; then | |
151 | # Enables the unit on first installation, creates new | |
152 | # symlinks on upgrades if the unit file has changed. | |
153 | deb-systemd-helper enable "$unit" >/dev/null || true | |
154 | else | |
155 | # Update the statefile to add new symlinks (if any), which need to be | |
156 | # cleaned up on purge. Also remove old symlinks. | |
157 | deb-systemd-helper update-state "$unit" >/dev/null || true | |
158 | fi | |
159 | done | |
160 | ||
161 | # FIXME: remove after beta is over and add hunk to actively remove the repo | |
162 | BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list" | |
163 | if ! test -f "$BETA_SOURCES"; then | |
164 | echo "Adding pvetest repo to '$BETA_SOURCES' to enable updates during Proxmox VE 8.0 BETA" | |
165 | echo "deb http://download.proxmox.com/debian/pve bookworm pvetest" | tee "$BETA_SOURCES" | |
166 | fi | |
167 | ||
168 | set_lvm_conf | |
169 | ||
170 | if test ! -e /proxmox_install_mode; then | |
171 | # modeled after code generated by dh_start | |
172 | for unit in ${UNITS}; do | |
173 | if test -n "$2"; then | |
174 | dh_action="reload-or-restart"; | |
175 | else | |
176 | dh_action="start" | |
177 | fi | |
178 | if systemctl -q is-enabled "$unit"; then | |
179 | deb-systemd-invoke $dh_action "$unit" | |
180 | fi | |
181 | done | |
182 | fi | |
183 | ||
184 | if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2-11~'; then | |
185 | if test -e /etc/apt/auth.conf ; then | |
186 | migrate_apt_auth_conf | |
187 | fi | |
188 | fi | |
189 | ;; | |
190 | ||
191 | abort-upgrade|abort-remove|abort-deconfigure) | |
192 | ;; | |
193 | ||
194 | *) echo "$0: didn't understand being called with \`$1'" 1>&2 | |
195 | exit 0;; | |
196 | esac | |
197 | ||
198 | exit 0 |