mysql: systemd support
authorAlex Suykov <alex.suykov@gmail.com>
Sat, 23 May 2015 10:15:18 +0000 (13:15 +0300)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 13 Jul 2015 20:40:25 +0000 (22:40 +0200)
Service startup follows sysv initscript and includes db init.

[Thomas: use a relative symlink rather than an absolute symlink.]

Signed-off-by: Alex Suykov <alex.suykov@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/mysql/mysql.mk
package/mysql/mysqld.service [new file with mode: 0644]

index 8718193257e936094703f6b2998e3babb9162cd9..c6d9f3a3568c5dcd44b0d91aa6a628cf7d04dfd1 100644 (file)
@@ -103,6 +103,14 @@ define MYSQL_INSTALL_INIT_SYSV
                $(TARGET_DIR)/etc/init.d/S97mysqld
 endef
 
+define MYSQL_INSTALL_INIT_SYSTEMD
+       $(INSTALL) -D -m 644 package/mysql/mysqld.service \
+               $(TARGET_DIR)/usr/lib/systemd/system/mysqld.service
+       mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+       ln -sf ../../../../usr/lib/systemd/system/mysqld.service \
+               $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/mysqld.service
+endef
+
 else
 MYSQL_CONF_OPTS += \
        --without-server
diff --git a/package/mysql/mysqld.service b/package/mysql/mysqld.service
new file mode 100644 (file)
index 0000000..2ded9c2
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=MySQL database server
+
+[Service]
+ExecStartPre=/bin/sh -c 'test -d /var/mysql/mysql || mysql_install_db --user=mysql --ldata=/var/mysql'
+ExecStart=/usr/bin/mysqld_safe
+Restart=always
+
+[Install]
+WantedBy=multi-user.target