matrix-synapse-py3.preinst 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh -e
  2. # Attempt to undo some of the braindamage caused by
  3. # https://github.com/matrix-org/package-synapse-debian/issues/18.
  4. #
  5. # Due to reasons [1], the old python2 matrix-synapse package will not stop the
  6. # service when the package is uninstalled. Our maintainer scripts will do the
  7. # right thing in terms of ensuring the service is enabled and unmasked, but
  8. # then do a `systemctl start matrix-synapse`, which of course does nothing -
  9. # leaving the old (py2) service running.
  10. #
  11. # There should normally be no reason for the service to be running during our
  12. # preinst, so we assume that if it *is* running, it's due to that situation,
  13. # and stop it.
  14. #
  15. # [1] dh_systemd_start doesn't do anything because it sees that there is an
  16. # init.d script with the same name, so leaves it to dh_installinit.
  17. #
  18. # dh_installinit doesn't do anything because somebody gave it a --no-start
  19. # for unknown reasons.
  20. if [ -x /bin/systemctl ]; then
  21. if /bin/systemctl --quiet is-active -- matrix-synapse; then
  22. echo >&2 "stopping existing matrix-synapse service"
  23. /bin/systemctl stop matrix-synapse || true
  24. fi
  25. fi
  26. #DEBHELPER#
  27. exit 0