Commit b2a0ffdeb2111d9d2d089a80f034a2902bde0060

Authored by Wiebe Cazemier
1 parent 7ab8deef

Fix deb maintainer scripts re-enabling a disabled service on upgrade

Showing 1 changed file with 15 additions and 5 deletions
debian/postinst
1 1 #!/bin/bash -e
2 2  
3   -if ! systemctl is-enabled --quiet flashmq.service; then
4   - echo "Enabling FlashMQ systemd service."
  3 +FRESH_INSTALL=true
  4 +
  5 +if [[ "$1" == "configure" && "$2" != "" ]]; then
  6 + FRESH_INSTALL=false
  7 +fi
  8 +
  9 +if "$FRESH_INSTALL"; then
  10 + echo "Fresh installation: enabling FlashMQ systemd service."
5 11 systemctl enable flashmq.service
  12 +else
  13 + echo "This is not a fresh installation: not (re)enabling FlashMQ systemd service."
  14 + # In case the service file changes, and to prevent systemd warnings 'service file changed' on upgrade.
  15 + systemctl daemon-reload
6 16 fi
7 17  
8   -if ! systemctl is-active --quiet flashmq.service; then
9   - echo "FlashMQ is not running, so we're starting it."
  18 +if systemctl is-enabled --quiet flashmq.service; then
  19 + echo "FlashMQ is marked as enabled, so starting it."
10 20 systemctl start flashmq.service
11 21 else
12   - echo "FlashMQ is already running."
  22 + echo "FlashMQ is marked as disabled, so not starting it."
13 23 fi
... ...