summary refs log tree commit diff
path: root/debian/matrix-synapse-py3.preinst
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-12-20 16:48:47 +0000
committerRichard van der Hoff <richard@matrix.org>2018-12-20 16:48:47 +0000
commit0b26feb42264e742968e2a573fa1390c667f41a8 (patch)
tree2b098ed5013ce06a5bb72e540d81d9dbe71a1442 /debian/matrix-synapse-py3.preinst
parentMerge pull request #4309 from KB1RD/KB1RD-fixes (diff)
parentClarify that py2 packages will continue to exist (diff)
downloadsynapse-0b26feb42264e742968e2a573fa1390c667f41a8.tar.xz
Merge branch 'master' into develop
Diffstat (limited to 'debian/matrix-synapse-py3.preinst')
-rw-r--r--debian/matrix-synapse-py3.preinst31
1 files changed, 31 insertions, 0 deletions
diff --git a/debian/matrix-synapse-py3.preinst b/debian/matrix-synapse-py3.preinst
new file mode 100644
index 0000000000..4b5612f050
--- /dev/null
+++ b/debian/matrix-synapse-py3.preinst
@@ -0,0 +1,31 @@
+#!/bin/sh -e
+
+# Attempt to undo some of the braindamage caused by
+# https://github.com/matrix-org/package-synapse-debian/issues/18.
+#
+# Due to reasons [1], the old python2 matrix-synapse package will not stop the
+# service when the package is uninstalled. Our maintainer scripts will do the
+# right thing in terms of ensuring the service is enabled and unmasked, but
+# then do a `systemctl start matrix-synapse`, which of course does nothing -
+# leaving the old (py2) service running.
+#
+# There should normally be no reason for the service to be running during our
+# preinst, so we assume that if it *is* running, it's due to that situation,
+# and stop it.
+#
+# [1] dh_systemd_start doesn't do anything because it sees that there is an
+#     init.d script with the same name, so leaves it to dh_installinit.
+#
+#     dh_installinit doesn't do anything because somebody gave it a --no-start
+#     for unknown reasons.
+
+if [ -x /bin/systemctl ]; then
+    if /bin/systemctl --quiet is-active -- matrix-synapse; then
+        echo >&2 "stopping existing matrix-synapse service"
+        /bin/systemctl stop matrix-synapse || true
+    fi
+fi
+
+#DEBHELPER#
+
+exit 0