From b2a0ffdeb2111d9d2d089a80f034a2902bde0060 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sat, 30 Jul 2022 15:30:08 +0200 Subject: [PATCH] Fix deb maintainer scripts re-enabling a disabled service on upgrade --- debian/postinst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/debian/postinst b/debian/postinst index d6b79e6..100d096 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,13 +1,23 @@ #!/bin/bash -e -if ! systemctl is-enabled --quiet flashmq.service; then - echo "Enabling FlashMQ systemd service." +FRESH_INSTALL=true + +if [[ "$1" == "configure" && "$2" != "" ]]; then + FRESH_INSTALL=false +fi + +if "$FRESH_INSTALL"; then + echo "Fresh installation: enabling FlashMQ systemd service." systemctl enable flashmq.service +else + echo "This is not a fresh installation: not (re)enabling FlashMQ systemd service." + # In case the service file changes, and to prevent systemd warnings 'service file changed' on upgrade. + systemctl daemon-reload fi -if ! systemctl is-active --quiet flashmq.service; then - echo "FlashMQ is not running, so we're starting it." +if systemctl is-enabled --quiet flashmq.service; then + echo "FlashMQ is marked as enabled, so starting it." systemctl start flashmq.service else - echo "FlashMQ is already running." + echo "FlashMQ is marked as disabled, so not starting it." fi -- libgit2 0.21.4