From 2a9f84b9a6e72f2d4facfaf49226736cdfe38d53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= <otto@mariadb.org>
Date: Mon, 11 Jan 2016 10:28:00 +0200
Subject: [PATCH] MDEV-9354: Debian: unmask the mysql.service on installation

Unmask the systemd mysql.service if left behind by mysql-server-5.6

Without this a simple 'apt-get install mariadb-server' would end
up with a system where mysqld is not running despite it was
running OK with mysql-server-5.6 installed, and users might wrongly
think mariadb-server package is broken when the real cause was
the removal of mysql-server-5.6 that left a /etc/systemd/system/
file behind pointing to /dev/null.
---
 debian/dist/Debian/mariadb-server-10.0.postinst | 5 +++++
 debian/dist/Ubuntu/mariadb-server-10.0.postinst | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/debian/dist/Debian/mariadb-server-10.0.postinst b/debian/dist/Debian/mariadb-server-10.0.postinst
index 19594fb910e..19a69ed00cb 100644
--- a/debian/dist/Debian/mariadb-server-10.0.postinst
+++ b/debian/dist/Debian/mariadb-server-10.0.postinst
@@ -264,6 +264,11 @@ fi
 
 db_stop # in case invoke failes
 
+# If we upgrade from MySQL mysql.service may be masked, which also
+# means init.d script is disabled. Unmask mysql service explicitely.
+# Ignore exit code as command is not available everywhere.
+deb-systemd-helper unmask mysql.service > /dev/null || true
+
 #DEBHELPER#
 
 exit 0
diff --git a/debian/dist/Ubuntu/mariadb-server-10.0.postinst b/debian/dist/Ubuntu/mariadb-server-10.0.postinst
index 1acfbc80970..2486a09a5af 100644
--- a/debian/dist/Ubuntu/mariadb-server-10.0.postinst
+++ b/debian/dist/Ubuntu/mariadb-server-10.0.postinst
@@ -280,6 +280,11 @@ fi
 
 db_stop # in case invoke failes
 
+# If we upgrade from MySQL mysql.service may be masked, which also
+# means init.d script is disabled. Unmask mysql service explicitely.
+# Ignore exit code as command is not available everywhere.
+deb-systemd-helper unmask mysql.service > /dev/null || true
+
 #DEBHELPER#
 
 exit 0
-- 
2.30.9