1 |
slords |
1.1 |
#!/bin/bash |
2 |
|
|
# |
3 |
|
|
# mdmonitor This starts, stops, and reloads the mdadm-based |
4 |
|
|
# software RAID monitoring and management facility |
5 |
|
|
# |
6 |
|
|
# chkconfig: 2345 15 85 |
7 |
|
|
# description: software RAID monitoring and management |
8 |
|
|
# config: /etc/mdadm.conf |
9 |
|
|
# |
10 |
|
|
# Copyright 2002 Red Hat, Inc. |
11 |
slords |
1.2 |
# |
12 |
|
|
### BEGIN INIT INFO |
13 |
|
|
# Default-Start: 2 3 4 5 |
14 |
|
|
# Default-Stop: 0 1 6 |
15 |
|
|
# Short-Description: Start and stop the MD software RAID monitor |
16 |
|
|
# Description: The mdmonitor service checks the status of all software |
17 |
|
|
# RAID arrays on the system. In the event that any of the arrays |
18 |
|
|
# transition into a degraded state, it notifies the system |
19 |
|
|
# administrator. Other options are available, see the mdadm.conf |
20 |
|
|
# and mdadm man pages for possible ways to configure this service. |
21 |
|
|
### END INIT INFO |
22 |
slords |
1.1 |
|
23 |
slords |
1.2 |
PIDFILE=/var/run/mdadm/mdadm.pid |
24 |
slords |
1.1 |
PATH=/sbin:/usr/sbin:$PATH |
25 |
|
|
RETVAL=0 |
26 |
slords |
1.2 |
OPTIONS="--monitor --scan -f --pid-file=$PIDFILE" |
27 |
slords |
1.1 |
|
28 |
|
|
prog=mdmonitor |
29 |
|
|
|
30 |
|
|
# Source function library. |
31 |
|
|
. /etc/rc.d/init.d/functions |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
usage () |
35 |
|
|
{ |
36 |
slords |
1.2 |
echo "Usage: service $prog {start|stop|status|restart|try-restart|force-reload}" |
37 |
slords |
1.1 |
RETVAL=1 |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
start () |
42 |
|
|
{ |
43 |
slords |
1.2 |
# Check we are being started with root perms or exit as mdadm won't |
44 |
|
|
# necessarily be able to open the devices it is supposed to monitor |
45 |
|
|
# otherwise, and will also spew SELinux warnings about being in the / |
46 |
|
|
# directory when spawning sendmail on a notification attempt |
47 |
|
|
[ `id -u` -eq 0 ] || return 4 |
48 |
|
|
# Make sure configuration file exists and has information we can use |
49 |
|
|
# MAILADDR or PROGRAM or both must be set in order to run mdadm --monitor |
50 |
|
|
[ -f /etc/mdadm.conf ] || return 6 |
51 |
|
|
grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || return 6 |
52 |
|
|
[ -x /sbin/mdadm ] || return 1 |
53 |
|
|
if [ -f "$PIDFILE" ]; then |
54 |
|
|
checkpid `cat $PIDFILE` && return 0 |
55 |
|
|
fi |
56 |
slords |
1.1 |
echo -n $"Starting $prog: " |
57 |
slords |
1.2 |
cd / |
58 |
|
|
daemon --user=root mdadm ${OPTIONS} |
59 |
|
|
ret=$? |
60 |
|
|
[ $ret -eq "0" ] && touch /var/lock/subsys/$prog |
61 |
slords |
1.1 |
echo |
62 |
slords |
1.2 |
return $ret |
63 |
slords |
1.1 |
} |
64 |
|
|
|
65 |
|
|
stop () |
66 |
|
|
{ |
67 |
slords |
1.2 |
[ `id -u` -eq 0 ] || return 4 |
68 |
|
|
[ -f /var/lock/subsys/$prog ] || return 0 |
69 |
slords |
1.1 |
echo -n "Killing $prog: " |
70 |
|
|
killproc mdadm |
71 |
|
|
echo |
72 |
|
|
rm -f /var/lock/subsys/$prog |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
restart () |
76 |
|
|
{ |
77 |
|
|
stop |
78 |
|
|
start |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
condrestart () |
82 |
|
|
{ |
83 |
slords |
1.2 |
[ -e /var/lock/subsys/$prog ] && restart || return 0 |
84 |
slords |
1.1 |
} |
85 |
|
|
|
86 |
|
|
|
87 |
|
|
case "$1" in |
88 |
slords |
1.2 |
start) start; RETVAL=$? ;; |
89 |
|
|
stop) stop; RETVAL=$? ;; |
90 |
|
|
status) status mdadm; RETVAL=$? ;; |
91 |
|
|
restart) restart; RETVAL=$? ;; |
92 |
|
|
reload) RETVAL=3 ;; |
93 |
|
|
condrestart|try-restart|force-reload) condrestart; RETVAL=$? ;; |
94 |
|
|
*) usage ; RETVAL=2 ;; |
95 |
slords |
1.1 |
esac |
96 |
|
|
|
97 |
|
|
exit $RETVAL |