diff options
Diffstat (limited to 'meta/recipes-extended/mdadm/files/mdadm.init')
-rw-r--r-- | meta/recipes-extended/mdadm/files/mdadm.init | 72 |
1 files changed, 72 insertions, 0 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 | |||
19 | MDADM=/sbin/mdadm | ||
20 | RUNDIR=/var/run/mdadm | ||
21 | PIDFILE=$RUNDIR/monitor.pid | ||
22 | DEBIANCONFIG=/etc/default/mdadm | ||
23 | |||
24 | test -x "$MDADM" || exit 0 | ||
25 | |||
26 | test -f /proc/mdstat || exit 0 | ||
27 | |||
28 | START_DAEMON=true | ||
29 | test -f $DEBIANCONFIG && . $DEBIANCONFIG | ||
30 | |||
31 | . /lib/lsb/init-functions | ||
32 | |||
33 | # Include functions | ||
34 | . /etc/init.d/functions | ||
35 | |||
36 | case "${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 | ;; | ||
69 | esac | ||
70 | |||
71 | exit 0 | ||
72 | |||