diff --git a/packaging/DEBIAN-multipath/postinst b/packaging/DEBIAN-multipath/postinst index 8c0cd67..31290f8 100644 --- a/packaging/DEBIAN-multipath/postinst +++ b/packaging/DEBIAN-multipath/postinst @@ -87,26 +87,38 @@ STANZA } restart_pve_services() { + # Bare statements (not `cmd && log ...`) so `set -e` actually aborts on + # failure instead of silently skipping past it — see tests/test-restart-services.sh. log "Restarting Proxmox VE services ..." - pvedaemon restart && log "pvedaemon restarted" - pveproxy restart && log "pveproxy restarted" + pvedaemon restart + log "pvedaemon restarted" + pveproxy restart + log "pveproxy restarted" + pvestatd restart + log "pvestatd restarted" + systemctl restart pve-ha-lrm pve-ha-crm + log "pve-ha-lrm, pve-ha-crm restarted" log "Done. Refresh your Proxmox browser tab." } -case "$1" in - configure) - log "Configuring truenas-proxmox-multipath (previous version: ${2:-none})" - install_plugin - install_ui - install_multipath_conf - restart_pve_services - ;; - abort-upgrade|abort-remove|abort-deconfigure) - ;; - *) - echo "$0: called with unknown argument '$1'" >&2 - exit 0 - ;; -esac +# Guard so tests can `source` this file (to exercise its functions) without +# running dpkg's maintainer-script logic below. +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + case "$1" in + configure) + log "Configuring truenas-proxmox-multipath (previous version: ${2:-none})" + install_plugin + install_ui + install_multipath_conf + restart_pve_services + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "$0: called with unknown argument '$1'" >&2 + exit 0 + ;; + esac -exit 0 + exit 0 +fi diff --git a/packaging/DEBIAN-multipath/postrm b/packaging/DEBIAN-multipath/postrm index eb5b943..f4d80a5 100644 --- a/packaging/DEBIAN-multipath/postrm +++ b/packaging/DEBIAN-multipath/postrm @@ -14,41 +14,57 @@ log() { echo "[truenas-proxmox-multipath] $*" | tee -a "$LOG_FILE" } -case "$1" in - remove|purge) - if [ -f "$PLUGIN_DST" ]; then - log "Removing ${PLUGIN_DST}" - rm -f "$PLUGIN_DST" - fi +restart_pve_services() { + # Bare statements (not `cmd && log ...`) so `set -e` actually aborts on + # failure instead of silently skipping past it — see tests/test-restart-services.sh. + log "Restarting Proxmox VE services ..." + pvedaemon restart + log "pvedaemon restarted" + pveproxy restart + log "pveproxy restarted" + pvestatd restart + log "pvestatd restarted" + systemctl restart pve-ha-lrm pve-ha-crm + log "pve-ha-lrm, pve-ha-crm restarted" +} - if [ -f "$JS_DST" ]; then - log "Removing ${JS_DST}" - rm -f "$JS_DST" - fi +# Guard so tests can `source` this file (to exercise its functions) without +# running dpkg's maintainer-script logic below. +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + case "$1" in + remove|purge) + if [ -f "$PLUGIN_DST" ]; then + log "Removing ${PLUGIN_DST}" + rm -f "$PLUGIN_DST" + fi - if [ -f "$TPL" ] && grep -qF 'truenas-multipath.js' "$TPL" 2>/dev/null; then - log "Removing