X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=debian%2Fpostinst;h=4c9a1f2500443006ccee05947007601fc2b46440;hb=5265a2d1a9dce716c92b375f2c9035d74e906533;hp=a5f4d7ac7616f19e2b816abd26f024304dced182;hpb=4e435ad13d28c494a157d190c81037faab58c2f0;p=pve-manager.git diff --git a/debian/postinst b/debian/postinst index a5f4d7ac..4c9a1f25 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,12 +1,97 @@ #!/bin/sh -# Abort if any command returns an error value +# Abort if any command returns an error value set -e -# This script is called as the last step of the installation of the -# package. All the package's files are in place, dpkg has already -# done its automatic conffile handling, and all the packages we depend -# of are already fully installed and configured. +# This script is called as the last step of the installation of the package. +# All the package's files are in place, dpkg has already done its automatic +# conffile handling, and all the packages we depend of are already fully +# installed and configured. + +set_lvm_conf() { + LVM_CONF_MARKER="# added by pve-manager to avoid scanning" + + # keep user changes afterwards provided marker is still there.. + if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then + return 0 # only do these changes once + fi + + OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)" + NEW_VALUE='global_filter=["r|/dev/zd.*|"]' + + export LVM_SUPPRESS_FD_WARNINGS=1 + + # check global_filter + # keep previous setting from our custom packaging if it is still there + if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then + SET_FILTER=1 + BACKUP=1 + fi + # should be the default since bullseye + if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then + SET_SCAN_LVS=1 + BACKUP=1 + fi + if test -n "$BACKUP"; then + echo "Backing up lvm.conf before setting pve-manager specific settings.." + cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak + fi + if test -n "$SET_FILTER"; then + echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:" + echo "$OLD_VALUE => $NEW_VALUE" + # comment out existing setting + sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf + # add new section with our setting + cat >> /etc/lvm/lvm.conf <> /etc/lvm/lvm.conf < /etc/apt/auth.conf.d/pve.conf + else + echo "Removing stale APT auth config from /etc/apt/auth.conf" + fi + echo "$output" > /etc/apt/auth.conf + fi +} case "$1" in triggered) @@ -18,10 +103,14 @@ case "$1" in test -f /etc/pve/local/pve-ssl.pem || exit 0; test -e /proxmox_install_mode && exit 0; + # the ExecStartPre doesn't triggers on service reload, so just in case + pvecm updatecerts --silent || true + deb-systemd-invoke reload-or-try-restart pvedaemon.service deb-systemd-invoke reload-or-try-restart pvestatd.service deb-systemd-invoke reload-or-try-restart pveproxy.service deb-systemd-invoke reload-or-try-restart spiceproxy.service + deb-systemd-invoke reload-or-try-restart pvescheduler.service exit 0;; @@ -32,56 +121,70 @@ case "$1" in mkdir /etc/pve 2>/dev/null || true if test ! -e /var/lib/pve-manager/apl-info/download.proxmox.com; then - mkdir -p /var/lib/pve-manager/apl-info - cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com - pveam update || true + mkdir -p /var/lib/pve-manager/apl-info + cp /usr/share/doc/pve-manager/aplinfo.dat /var/lib/pve-manager/apl-info/download.proxmox.com + pveam update || true + fi + + # Always try to clean old entry, even when proxmox-mail-forward entry is already present. + # This ensures it will still be cleaned after an upgrade following a downgrade. + if test -f /root/.forward; then + sed -i '\!|/usr/bin/pvemailforward!d' /root/.forward fi - if ! test -f /root/.forward || ! grep -q '|/usr/bin/pvemailforward' /root/.forward; then - echo '|/usr/bin/pvemailforward' >>/root/.forward + if ! test -f /root/.forward || ! grep -q '|/usr/bin/proxmox-mail-forward' /root/.forward; then + echo '|/usr/bin/proxmox-mail-forward' >>/root/.forward fi systemctl --system daemon-reload >/dev/null || true # same as dh_systemd_enable (code copied) - UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvesr.timer pve-daily-update.timer" + UNITS="pvedaemon.service pveproxy.service spiceproxy.service pvestatd.service pvebanner.service pvescheduler.service pve-daily-update.timer" NO_RESTART_UNITS="pvenetcommit.service pve-guests.service" for unit in ${UNITS} ${NO_RESTART_UNITS}; do - deb-systemd-helper unmask "$unit" >/dev/null || true - - # was-enabled defaults to true, so new installations run enable. - if deb-systemd-helper --quiet was-enabled "$unit"; then - # Enables the unit on first installation, creates new - # symlinks on upgrades if the unit file has changed. - deb-systemd-helper enable "$unit" >/dev/null || true - else - # Update the statefile to add new symlinks (if any), which need to be - # cleaned up on purge. Also remove old symlinks. - deb-systemd-helper update-state "$unit" >/dev/null || true - fi + deb-systemd-helper unmask "$unit" >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled "$unit"; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable "$unit" >/dev/null || true + else + # Update the statefile to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state "$unit" >/dev/null || true + fi done + # FIXME: remove after beta is over and add hunk to actively remove the repo + BETA_SOURCES="/etc/apt/sources.list.d/pvetest-for-beta.list" + if test -f "$BETA_SOURCES" && dpkg --compare-versions "$2" 'lt' '8.0.2' && dpkg --compare-versions "$2" 'gt' '8.0~'; then + echo "Removing the during beta added pvetest repository file again" + rm -v "$BETA_SOURCES" || true + fi + + set_lvm_conf + if test ! -e /proxmox_install_mode; then - # modeled after code generated by dh_start - for unit in ${UNITS}; do - if test -n "$2"; then - dh_action="reload-or-try-restart"; - else - dh_action="start" - fi - if systemctl -q is-enabled "$unit"; then - deb-systemd-invoke $dh_action "$unit" - fi - done + # modeled after code generated by dh_start + for unit in ${UNITS}; do + if test -n "$2"; then + dh_action="reload-or-restart"; + else + dh_action="start" + fi + if systemctl -q is-enabled "$unit"; then + deb-systemd-invoke $dh_action "$unit" + fi + done fi - # TODO: remove once PVE 7.0 is released - if test -n "$2"; then - if dpkg --compare-versions "$2" 'lt' '6.0-11'; then - newaliases || true - fi + if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.2-11~'; then + if test -e /etc/apt/auth.conf ; then + migrate_apt_auth_conf + fi fi ;; @@ -92,7 +195,4 @@ case "$1" in exit 0;; esac -# FIXME: remove in 7.0 -dpkg-maintscript-helper rm_conffile /etc/apt/apt.conf.d/75pveconf 6.0-0\+3 pve-manager -- "$@" - exit 0