PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/rc4.d/S25mdadm

http://github.com/brinkman83/bashrc
Shell | 79 lines | 49 code | 8 blank | 22 comment | 5 complexity | 62dd8d0b38179b325bc11aa5f80357e2 MD5 | raw file
 1#!/bin/sh
 2#
 3# Start the MD monitor daemon for all active MD arrays if desired.
 4#
 5# Copyright © 2001-2005 Mario Jou/3en <joussen@debian.org>
 6# Copyright © 2005-2008 Martin F. Krafft <madduck@debian.org>
 7# Distributable under the terms of the GNU GPL version 2.
 8#
 9### BEGIN INIT INFO
10# Provides:          mdadm
11# Required-Start:    checkroot
12# Required-Stop:     umountroot
13# Should-Start:      module-init-tools
14# Default-Start:     S
15# Default-Stop:      0 6
16# Short-Description: MD monitoring daemon
17# Description:       mdadm provides a monitor mode, in which it will scan for
18#                    problems with the MD devices. If a problem is found, the
19#                    administrator is alerted via email, or a custom script is
20#                    run.
21### END INIT INFO
22#
23set -eu
24
25MDADM=/sbin/mdadm
26RUNDIR=/var/run/mdadm
27PIDFILE=$RUNDIR/monitor.pid
28DEBIANCONFIG=/etc/default/mdadm
29
30test -x "$MDADM" || exit 0
31
32test -f /proc/mdstat || exit 0
33
34START_DAEMON=true
35test -f $DEBIANCONFIG && . $DEBIANCONFIG
36
37. /lib/lsb/init-functions
38
39is_true()
40{
41  case "${1:-}" in
42    [Yy]es|[Yy]|1|[Tt]|[Tt]rue) return 0;;
43    *) return 1;
44  esac
45}
46
47case "${1:-}" in
48  start)
49    if is_true $START_DAEMON; then
50      log_daemon_msg "Starting MD monitoring service" "mdadm --monitor"
51      mkdir -p $RUNDIR
52      set +e
53      start-stop-daemon -S -p $PIDFILE -x $MDADM -- \
54        --monitor --pid-file $PIDFILE --daemonise --scan ${DAEMON_OPTIONS:-}
55      log_end_msg $?
56      set -e
57    fi
58    ;;
59  stop)
60    if [ -f $PIDFILE ] ; then
61      log_daemon_msg "Stopping MD monitoring service" "mdadm --monitor"
62      set +e
63      start-stop-daemon -K -p $PIDFILE -x $MDADM
64      rm -f $PIDFILE
65      log_end_msg $?
66      set -e
67    fi
68    ;;
69  restart|reload|force-reload)
70    ${0:-} stop
71    ${0:-} start
72    ;;
73  *)
74    echo "Usage: ${0:-} {start|stop|restart|reload|force-reload}" >&2
75    exit 1
76    ;;
77esac
78
79exit 0