]> TLD Linux GIT Repositories - packages/mdadm.git/blob - mdadm.init
- updated to 4.3
[packages/mdadm.git] / mdadm.init
1 #!/bin/sh
2 #
3 # mdadm         This shell script takes care of starting and stopping mdadm.
4 #
5 # chkconfig:    2345 80 30
6 # description:  RAID array monitoring
7 #
8 # processname:  mdadm
9 # config:       /etc/mdadm.conf
10 # pidfile:      /var/run/mdadm.pid
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # Source mdadm configuration.
16 if [ -f /etc/sysconfig/mdadm ]; then
17         . /etc/sysconfig/mdadm
18 fi
19
20 start() {
21         # Start daemons.
22         if [ ! -f /var/lock/subsys/mdadm ]; then
23                 [ -n "$MDADM_EMAIL" ] && echo "WARNING: sysconfig/mdadm:MDADM_EMAIL no longer supported. Please use /etc/mdadm.conf:MAILADDR setting." >&2
24                 msg_starting mdadm
25                 daemon /sbin/mdadm --monitor --scan --daemonise --pid-file /var/run/mdadm.pid ${MDADM_OPTS}
26                 RETVAL=$?
27                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mdadm
28         else
29                 msg_already_running mdadm
30         fi
31 }
32
33 stop() {
34         # Stop daemons.
35         if [ -f /var/lock/subsys/mdadm ]; then
36                 msg_stopping mdadm
37                 killproc --pidfile /var/run/mdadm.pid mdadm
38                 rm -f /var/lock/subsys/mdadm >/dev/null 2>&1
39         else
40                 msg_not_running mdadm
41         fi
42 }
43
44 condrestart() {
45         if [ -f /var/lock/subsys/mdadm ]; then
46                 stop
47                 start
48         else
49                 msg_not_running mdadm
50                 RETVAL=$1
51         fi
52 }
53
54 RETVAL=0
55 # See how we were called.
56 case "$1" in
57   start)
58         start
59         ;;
60   stop)
61         stop
62         ;;
63   restart)
64         stop
65         start
66         ;;
67   try-restart)
68         condrestart 0
69         ;;
70   force-reload)
71         condrestart 7
72         ;;
73   status)
74         cat /proc/mdstat
75         status mdadm
76         exit $?
77         ;;
78   *)
79         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
80         exit 3
81 esac
82
83 exit $RETVAL