summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
authorZheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>2019-02-21 14:06:42 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-25 22:27:38 +0000
commitf1c7d5d719365448c7cd43e699b3449488fd3bd8 (patch)
tree9c50165a9db965cea6a60e4e56e8849622425176 /meta/recipes-extended
parent7756de368de1654f059343c3cd766a43d10b5d9b (diff)
downloadpoky-f1c7d5d719365448c7cd43e699b3449488fd3bd8.tar.gz
mdadm: add init and service scripts
Add init script and service file for sysvinit and systemd. (From OE-Core rev: 4556380fc582646506fb69a18ad2c8ded904b8ba) Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com> Signed-off-by: Hong Liu <hongl.fnst@cn.fujitsu.com> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/mdadm/files/mdadm.init72
-rw-r--r--meta/recipes-extended/mdadm/files/mdmonitor.service19
-rw-r--r--meta/recipes-extended/mdadm/mdadm_4.0.bb17
3 files changed, 106 insertions, 2 deletions
diff --git a/meta/recipes-extended/mdadm/files/mdadm.init b/meta/recipes-extended/mdadm/files/mdadm.init
new file mode 100644
index 0000000000..cab91b9acc
--- /dev/null
+++ b/meta/recipes-extended/mdadm/files/mdadm.init
@@ -0,0 +1,72 @@
1#!/bin/sh
2#
3# Start the MD monitor daemon for all active MD arrays if desired.
4#
5### BEGIN INIT INFO
6# Provides: mdadm
7# Required-Start: $local_fs $syslog mdadm-raid
8# Required-Stop: $local_fs $syslog mdadm-raid
9# Default-Start: 2 3 4 5
10# Default-Stop: 0 1 6
11# Short-Description: MD monitoring daemon
12# Description: mdadm provides a monitor mode, in which it will scan for
13# problems with the MD devices. If a problem is found, the
14# administrator is alerted via email, or a custom script is
15# run.
16### END INIT INFO
17#
18
19MDADM=/sbin/mdadm
20RUNDIR=/var/run/mdadm
21PIDFILE=$RUNDIR/monitor.pid
22DEBIANCONFIG=/etc/default/mdadm
23
24test -x "$MDADM" || exit 0
25
26test -f /proc/mdstat || exit 0
27
28START_DAEMON=true
29test -f $DEBIANCONFIG && . $DEBIANCONFIG
30
31. /lib/lsb/init-functions
32
33# Include functions
34. /etc/init.d/functions
35
36case "${1:-}" in
37 start)
38 if is_true $START_DAEMON; then
39 log_daemon_msg "Starting MD monitoring service" "mdadm --monitor"
40 mkdir -p $RUNDIR
41 start-stop-daemon -S -p $PIDFILE -x $MDADM -- \
42 --monitor --pid-file $PIDFILE --daemonise --scan ${DAEMON_OPTIONS:-}
43 RETVAL=$?
44 log_end_msg $RETVAL
45 exit $RETVAL
46 fi
47 ;;
48 stop)
49 if [ -f $PIDFILE ] ; then
50 log_daemon_msg "Stopping MD monitoring service" "mdadm --monitor"
51 start-stop-daemon -K -p $PIDFILE -x $MDADM
52 RETVAL=$?
53 rm -f $PIDFILE
54 log_end_msg $RETVAL
55 exit $RETVAL
56 fi
57 ;;
58 status)
59 status -p $PIDFILE "$MDADM" && exit 0 || exit $?
60 ;;
61 restart|reload|force-reload)
62 ${0:-} stop
63 ${0:-} start
64 ;;
65 *)
66 echo "Usage: ${0:-} {start|stop|status|restart|reload|force-reload}" >&2
67 exit 1
68 ;;
69esac
70
71exit 0
72
diff --git a/meta/recipes-extended/mdadm/files/mdmonitor.service b/meta/recipes-extended/mdadm/files/mdmonitor.service
new file mode 100644
index 0000000000..bd243b4498
--- /dev/null
+++ b/meta/recipes-extended/mdadm/files/mdmonitor.service
@@ -0,0 +1,19 @@
1# This file is part of mdadm.
2#
3# mdadm is free software; you can redistribute it and/or modify it
4# under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7
8[Unit]
9Description=Software RAID monitoring and management
10ConditionPathExists=/etc/mdadm.conf
11
12[Service]
13Type=forking
14PIDFile=/var/run/mdadm/mdadm.pid
15EnvironmentFile=-/etc/sysconfig/mdmonitor
16ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
17
18[Install]
19WantedBy=multi-user.target
diff --git a/meta/recipes-extended/mdadm/mdadm_4.0.bb b/meta/recipes-extended/mdadm/mdadm_4.0.bb
index 2c4d88a9e7..8155ae41b4 100644
--- a/meta/recipes-extended/mdadm/mdadm_4.0.bb
+++ b/meta/recipes-extended/mdadm/mdadm_4.0.bb
@@ -24,12 +24,14 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \
24 file://0001-Use-CC-to-check-for-implicit-fallthrough-warning-sup.patch \ 24 file://0001-Use-CC-to-check-for-implicit-fallthrough-warning-sup.patch \
25 file://0001-use-memmove-instead-of-memcpy-on-overlapping-region.patch \ 25 file://0001-use-memmove-instead-of-memcpy-on-overlapping-region.patch \
26 file://0001-Disable-gcc8-warnings.patch \ 26 file://0001-Disable-gcc8-warnings.patch \
27 file://mdadm.init \
28 file://mdmonitor.service \
27 " 29 "
28SRC_URI[md5sum] = "2cb4feffea9167ba71b5f346a0c0a40d" 30SRC_URI[md5sum] = "2cb4feffea9167ba71b5f346a0c0a40d"
29SRC_URI[sha256sum] = "1d6ae7f24ced3a0fa7b5613b32f4a589bb4881e3946a5a2c3724056254ada3a9" 31SRC_URI[sha256sum] = "1d6ae7f24ced3a0fa7b5613b32f4a589bb4881e3946a5a2c3724056254ada3a9"
30 32
31CFLAGS += "-fno-strict-aliasing" 33CFLAGS += "-fno-strict-aliasing"
32inherit autotools-brokensep 34inherit autotools-brokensep systemd
33 35
34EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CXFLAGS="${CFLAGS}"' 36EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CXFLAGS="${CFLAGS}"'
35# PPC64 and MIPS64 uses long long for u64 in the kernel, but powerpc's asm/types.h 37# PPC64 and MIPS64 uses long long for u64 in the kernel, but powerpc's asm/types.h
@@ -51,7 +53,17 @@ do_install() {
51 autotools_do_install 53 autotools_do_install
52} 54}
53 55
54inherit ptest 56do_install_append() {
57 install -d ${D}/${sysconfdir}/
58 install -m 644 ${S}/mdadm.conf-example ${D}${sysconfdir}/mdadm.conf
59 install -d ${D}/${systemd_unitdir}/system
60 install -m 644 ${S}/systemd/mdmonitor.service ${D}/${systemd_unitdir}/system
61 install -d ${D}/${sysconfdir}/init.d
62 install -m 755 ${WORKDIR}/mdadm.init ${D}${sysconfdir}/init.d/mdmonitor
63}
64
65SYSTEMD_SERVICE_${PN} = "mdmonitor.service"
66SYSTEMD_AUTO_ENABLE = "disable"
55 67
56do_compile_ptest() { 68do_compile_ptest() {
57 oe_runmake test 69 oe_runmake test
@@ -67,6 +79,7 @@ do_install_ptest() {
67 install -D -m 755 $prg ${D}${PTEST_PATH}/ 79 install -D -m 755 $prg ${D}${PTEST_PATH}/
68 done 80 done
69} 81}
82
70RDEPENDS_${PN}-ptest += "bash" 83RDEPENDS_${PN}-ptest += "bash"
71RRECOMMENDS_${PN}-ptest += " \ 84RRECOMMENDS_${PN}-ptest += " \
72 coreutils \ 85 coreutils \