summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/mdadm
diff options
context:
space:
mode:
authorZheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>2019-02-21 14:06:27 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-25 10:43:06 +0000
commit366fe3d01e623f30b81f3224dc556af8c778fc48 (patch)
tree21bdfb9ae5a57a9ade3e86490ca6acfbc4b6a1b3 /meta/recipes-extended/mdadm
parente34b0865c7deee5fac286ac076ebcbd529005247 (diff)
downloadpoky-366fe3d01e623f30b81f3224dc556af8c778fc48.tar.gz
mdadm: add init and service scripts
Add init script and service file for sysvinit and systemd. (From OE-Core rev: a6222a41c54fb9feebb980e57bcc8a572f93acd1) Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com> Signed-off-by: Hong Liu <hongl.fnst@cn.fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/mdadm')
-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.1.bb16
3 files changed, 106 insertions, 1 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.1.bb b/meta/recipes-extended/mdadm/mdadm_4.1.bb
index 7663a6b7ec..2d7ade68c5 100644
--- a/meta/recipes-extended/mdadm/mdadm_4.1.bb
+++ b/meta/recipes-extended/mdadm/mdadm_4.1.bb
@@ -17,11 +17,16 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \
17 file://0001-Use-CC-to-check-for-implicit-fallthrough-warning-sup.patch \ 17 file://0001-Use-CC-to-check-for-implicit-fallthrough-warning-sup.patch \
18 file://0001-Compute-abs-diff-in-a-standard-compliant-way.patch \ 18 file://0001-Compute-abs-diff-in-a-standard-compliant-way.patch \
19 file://0001-fix-gcc-8-format-truncation-warning.patch \ 19 file://0001-fix-gcc-8-format-truncation-warning.patch \
20 file://mdadm.init \
21 file://mdmonitor.service \
20 " 22 "
21SRC_URI[md5sum] = "51bf3651bd73a06c413a2f964f299598" 23SRC_URI[md5sum] = "51bf3651bd73a06c413a2f964f299598"
22SRC_URI[sha256sum] = "ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a" 24SRC_URI[sha256sum] = "ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a"
23 25
24inherit autotools-brokensep ptest 26inherit autotools-brokensep ptest systemd
27
28SYSTEMD_SERVICE_${PN} = "mdmonitor.service"
29SYSTEMD_AUTO_ENABLE = "disable"
25 30
26CFLAGS_append_toolchain-clang = " -Wno-error=address-of-packed-member" 31CFLAGS_append_toolchain-clang = " -Wno-error=address-of-packed-member"
27 32
@@ -46,6 +51,15 @@ do_install() {
46 autotools_do_install 51 autotools_do_install
47} 52}
48 53
54do_install_append() {
55 install -d ${D}/${sysconfdir}/
56 install -m 644 ${S}/mdadm.conf-example ${D}${sysconfdir}/mdadm.conf
57 install -d ${D}/${systemd_unitdir}/system
58 install -m 644 ${WORKDIR}/mdmonitor.service ${D}/${systemd_unitdir}/system
59 install -d ${D}/${sysconfdir}/init.d
60 install -m 755 ${WORKDIR}/mdadm.init ${D}${sysconfdir}/init.d/mdmonitor
61}
62
49do_compile_ptest() { 63do_compile_ptest() {
50 oe_runmake test 64 oe_runmake test
51} 65}