3 # Abort if any command returns an error value
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.
13 LVM_CONF_MARKER
="# added by pve-manager to avoid scanning"
15 # keep user changes afterwards provided marker is still there..
16 if grep -qLF "$LVM_CONF_MARKER" /etc
/lvm
/lvm.conf
&& test -z "$FORCE"; then
17 return 0 # only do these changes once
20 export LVM_SUPPRESS_FD_WARNINGS
=1
22 OLD_VALUE
="$(lvmconfig --typeconfig diff devices/global_filter || true)"
23 NEW_VALUE
='global_filter=["r|/dev/zd.*|","r|/dev/rbd.*|"]'
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")\
28 ||
(echo "$OLD_VALUE" |
grep -qF '="r|/dev/zd.*|"');
32 # print warning if global_filter is set but not our old/new default
33 elif test -n "$OLD_VALUE"\
34 && ! echo "$OLD_VALUE" |
grep -qF '="r|/dev/zd.*|"'\
35 && ! echo "$OLD_VALUE" |
grep -qF "$NEW_VALUE";
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."
40 # should be the default since bullseye
41 if lvmconfig
--typeconfig full devices
/scan_lvs |
grep -qv 'scan_lvs=0'; then
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
49 if test -n "$SET_FILTER"; then
50 echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols and rbds from being scanned:"
51 echo "$OLD_VALUE => $NEW_VALUE"
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
56 cat >> /etc
/lvm
/lvm.conf
<<EOF
58 $LVM_CONF_MARKER ZFS zvols and Ceph rbds
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
71 $LVM_CONF_MARKER LVM volumes
77 if ! lvmconfig
--validate; then
78 echo "Invalid LVM config detected - restoring from /etc/lvm/lvm.conf.bak"
79 mv /etc
/lvm
/lvm.conf.bak
/etc
/lvm
/lvm.conf
83 migrate_apt_auth_conf
() {
89 if echo "$l" |
grep -q "^machine enterprise.proxmox.com/debian/pve"; then
91 elif echo "$l" |
grep -q "machine"; then
95 if test "$match" = "1"; then
96 removed
="$removed\n$l"
100 done < /etc
/apt
/auth.conf
102 if test -n "$removed"; then
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
107 echo "Removing stale APT auth config from /etc/apt/auth.conf"
109 echo "$output" > /etc
/apt
/auth.conf
115 # We don't print a status message here, as dpkg already said
116 # "Processing triggers for ...".
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;
121 test -e /proxmox_install_mode
&& exit 0;
123 # the ExecStartPre doesn't triggers on service reload, so just in case
124 pvecm updatecerts
--silent || true
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
130 deb-systemd-invoke reload-or-try-restart pvescheduler.service
135 # Configure this package. If the package must prompt the user for
136 # information, do it here.
138 mkdir
/etc
/pve
2>/dev
/null || true
140 if test ! -e /var
/lib
/pve-manager
/apl-info
/download.proxmox.com
; then
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
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
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
156 systemctl
--system daemon-reload
>/dev
/null || true
158 # same as dh_systemd_enable (code copied)
160 UNITS
="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer"
161 NO_RESTART_UNITS
="pvenetcommit.service pve-guests.service"
163 for unit
in ${UNITS} ${NO_RESTART_UNITS}; do
164 deb-systemd-helper unmask
"$unit" >/dev
/null || true
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
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
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"
180 if test -f "$BETA_SOURCES" && dpkg
--compare-versions "$2" 'lt' '8.0.2' && dpkg
--compare-versions "$2" 'gt' '8.0~'; then
181 echo "Removing the during beta added pvetest repository file again"
182 rm -v "$BETA_SOURCES" || true
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
193 if test ! -e /proxmox_install_mode
; then
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";
201 if systemctl
-q is-enabled
"$unit"; then
202 deb-systemd-invoke
$dh_action "$unit"
207 if test ! -e /proxmox_install_mode
&& test -n "$2" && dpkg
--compare-versions "$2" 'lt' '7.2-11~'; then
208 if test -e /etc
/apt
/auth.conf
; then
209 migrate_apt_auth_conf
214 abort-upgrade|abort-remove|abort-deconfigure
)
217 *) echo "$0: didn't understand being called with \`$1'" 1>&2