Skip to contentSkip to conversation

mariadb: add systemd unit file

PATCH New [email protected] 1 participant 2 messages Aug 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mariadb: add systemd unit file

From: Chen Qi <[email protected]>

The service file mainly comes from Fedora20.

This patch also adds a configuration file under /etc/tmpfiles.d so that mysqld could start correctly.

---
 .../recipes-support/mysql/mariadb/mysqld.service   |   15 +++++++++++++++
 meta-oe/recipes-support/mysql/mariadb_5.5.38.inc   |   20 ++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-support/mysql/mariadb/mysqld.service
meta-oe/recipes-support/mysql/mariadb/mysqld.service new file +15 -0
new file mode 100644
index 0000000..18ad8d5
@@ -0,0 +1,15 @@
+[Unit]
+Description=MariaDB database server
+After=syslog.target
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@
+TimeoutSec=300
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
meta-oe/recipes-support/mysql/mariadb_5.5.38.inc +18 -2
index 8a73833..4e9a9e5 100644
@@ -9,6 +9,7 @@ SRC_URI = "http://mirror.stshosting.co.uk/mariadb/mariadb-${PV}/source/mariadb-$
            file://remove-bad-path.patch \
            file://fix-mysqlclient-r-version.patch \
            file://my.cnf \
+           file://mysqld.service \
           "
 
 SRC_URI[md5sum] = "fa9ba00b084b95a45fab70860c412f10"
@@ -18,7 +19,7 @@ S = "${WORKDIR}/mariadb-${PV}"
 
 BINCONFIG_GLOB = "mysql_config"
 
-inherit cmake gettext binconfig update-rc.d useradd
+inherit cmake gettext binconfig update-rc.d useradd systemd
 
 INITSCRIPT_PACKAGES = "${PN}-server"
 INITSCRIPT_NAME = "mysqld"
@@ -28,6 +29,10 @@ USERADD_PACKAGES = "${PN}-server"
 USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql"
 GROUPADD_PARAM_${PN}-server = "--system mysql"
 
+SYSTEMD_PACKAGES = "mariadb-server"
+SYSTEMD_SERVICE_mariadb-server = "mysqld.service"
+SYSTEMD_AUTO_ENABLE_mariadb-server = "disable"
+
 EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"
 
 python __anonymous() {
@@ -112,6 +117,16 @@ do_install() {
     install -d ${D}/${sysconfdir}/init.d
     install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
     mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld
+
+    install -d ${D}${systemd_unitdir}/system
+    install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
+    sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service
+
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+	install -d ${D}${sysconfdir}/tmpfiles.d
+	echo "f /var/log/mysqld.err 0640 mysql mysql -" \
+            > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
+    fi
 }
 
 pkg_postinst_${PN}-server () {
@@ -247,7 +262,8 @@ FILES_${PN}-server = "\
     ${datadir}/mysql/ \
     ${localstatedir}/mysql/ \
     ${sysconfdir}/init.d \
-    ${sysconfdir}/my.cnf"
+    ${sysconfdir}/my.cnf \
+    ${sysconfdir}/tmpfiles.d"
 
 DESCRIPTION_${PN}-leftovers = "unpackaged and probably unneeded files for ${PN}"
 FILES_${PN}-leftovers = "/"
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 2/2 apache2: add systemd unit file

From: Chen Qi <[email protected]>

Add systemd unit file for apache2.

---
 .../recipes-httpd/apache2/apache2_2.4.10.bb        |   13 +++++++++++--
 .../recipes-httpd/apache2/files/apache2.service    |   14 ++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 meta-webserver/recipes-httpd/apache2/files/apache2.service
meta-webserver/recipes-httpd/apache2/apache2_2.4.10.bb +11 -2
index 614dd4e..0356029 100644
@@ -18,7 +18,8 @@ SRC_URI = "http://www.apache.org/dist/httpd/httpd-${PV}.tar.bz2 \
            file://npn-patch-2.4.7.patch \
            file://0001-configure-use-pkg-config-for-PCRE-detection.patch \
            file://init \
-           file://apache2-volatile.conf"
+           file://apache2-volatile.conf \
+           file://apache2.service"
 
 LIC_FILES_CHKSUM = "file://LICENSE;md5=dbff5a2b542fa58854455bf1a0b94b83"
 SRC_URI[md5sum] = "44543dff14a4ebc1e9e2d86780507156"
@@ -26,7 +27,10 @@ SRC_URI[sha256sum] = "176c4dac1a745f07b7b91e7f4fd48f9c48049fa6f088efe758d61d9738
 
 S = "${WORKDIR}/httpd-${PV}"
 
-inherit autotools update-rc.d pkgconfig
+inherit autotools update-rc.d pkgconfig systemd
+
+SYSTEMD_SERVICE_${PN} = "apache2.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
 
 SSTATE_SCAN_FILES += "apxs config_vars.mk config.nice"
 
@@ -81,6 +85,11 @@ do_install_append() {
         install -d ${D}${sysconfdir}/tmpfiles.d/
         install -m 0644 ${WORKDIR}/apache2-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
     fi
+
+    install -d ${D}${systemd_unitdir}/system
+    install -m 0644 ${WORKDIR}/apache2.service ${D}${systemd_unitdir}/system
+    sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/apache2.service
+    sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' ${D}${systemd_unitdir}/system/apache2.service
 }
 
 SYSROOT_PREPROCESS_FUNCS += "apache_sysroot_preprocess"
meta-webserver/recipes-httpd/apache2/files/apache2.service new file +14 -0
new file mode 100644
index 0000000..f4bcf9e
@@ -0,0 +1,14 @@
+[Unit]
+Decription=The Apache HTTP Server
+After=network.target remote-fs.target nss-lookup.target
+
+[Service]
+Type=simple
+Environment=LANG=C
+ExecStart=@SBINDIR@/httpd -DFOREGROUND -D SSL -D PHP5 -k start
+ExecStop=@BASE_BINDIR@/kill -WINCH ${MAINPID}
+KillSignal=SIGCONT
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
Signature · 1 line
1.7.9.5