2004-09-09 08:24:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# mdmonitor This starts, stops, and reloads the mdadm-based
|
|
|
|
# software RAID monitoring and management facility
|
|
|
|
#
|
2004-09-09 08:27:45 +00:00
|
|
|
# chkconfig: 2345 15 85
|
2004-09-09 08:24:56 +00:00
|
|
|
# description: software RAID monitoring and management
|
|
|
|
# config: /etc/mdadm.conf
|
|
|
|
#
|
|
|
|
# Copyright 2002 Red Hat, Inc.
|
2007-07-06 16:39:50 +00:00
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Start and stop the MD software RAID monitor
|
|
|
|
# Description: The mdmonitor service checks the status of all software
|
|
|
|
# RAID arrays on the system. In the event that any of the arrays
|
|
|
|
# transition into a degraded state, it notifies the system
|
|
|
|
# administrator. Other options are available, see the mdadm.conf
|
|
|
|
# and mdadm man pages for possible ways to configure this service.
|
|
|
|
### END INIT INFO
|
2004-09-09 08:24:56 +00:00
|
|
|
|
2007-07-03 20:04:11 +00:00
|
|
|
PIDFILE=/var/run/mdadm/mdadm.pid
|
2004-09-09 08:24:56 +00:00
|
|
|
PATH=/sbin:/usr/sbin:$PATH
|
|
|
|
RETVAL=0
|
2007-07-03 20:04:11 +00:00
|
|
|
OPTIONS="--monitor --scan -f --pid-file=$PIDFILE"
|
2004-09-09 08:24:56 +00:00
|
|
|
|
|
|
|
prog=mdmonitor
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
|
|
|
|
usage ()
|
|
|
|
{
|
2007-07-06 16:39:50 +00:00
|
|
|
echo "Usage: service $prog {start|stop|status|restart|try-restart|force-reload}"
|
2004-09-09 08:24:56 +00:00
|
|
|
RETVAL=1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
start ()
|
|
|
|
{
|
2009-10-02 19:36:57 +00:00
|
|
|
# (Re)start mdmon to take over monitoring of mdmon started from the initrd
|
|
|
|
if [ -f /dev/.mdadm/*.pid ]; then
|
|
|
|
origprog="$prog"; prog="mdmon"
|
|
|
|
action $"Starting $prog: " /sbin/mdmon /proc/mdstat /
|
|
|
|
prog="$origprog"
|
|
|
|
fi
|
2007-07-03 20:04:11 +00:00
|
|
|
# Make sure configuration file exists and has information we can use
|
|
|
|
# MAILADDR or PROGRAM or both must be set in order to run mdadm --monitor
|
|
|
|
[ -f /etc/mdadm.conf ] || return 6
|
|
|
|
grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || return 6
|
|
|
|
if [ -f "$PIDFILE" ]; then
|
|
|
|
checkpid `cat $PIDFILE` && return 0
|
|
|
|
fi
|
2004-09-09 08:24:56 +00:00
|
|
|
echo -n $"Starting $prog: "
|
2007-10-19 16:38:10 +00:00
|
|
|
cd /
|
2007-07-03 20:04:11 +00:00
|
|
|
daemon --user=root mdadm ${OPTIONS}
|
2005-05-16 22:03:20 +00:00
|
|
|
ret=$?
|
|
|
|
[ $ret -eq "0" ] && touch /var/lock/subsys/$prog
|
2004-09-09 08:27:45 +00:00
|
|
|
echo
|
2005-05-16 22:03:20 +00:00
|
|
|
return $ret
|
2004-09-09 08:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop ()
|
|
|
|
{
|
2007-07-06 16:39:50 +00:00
|
|
|
[ -f /var/lock/subsys/$prog ] || return 0
|
2004-09-09 08:27:45 +00:00
|
|
|
echo -n "Killing $prog: "
|
2004-09-09 08:24:56 +00:00
|
|
|
killproc mdadm
|
2004-09-09 08:27:45 +00:00
|
|
|
echo
|
2004-09-09 08:24:56 +00:00
|
|
|
rm -f /var/lock/subsys/$prog
|
|
|
|
}
|
|
|
|
|
|
|
|
restart ()
|
|
|
|
{
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
condrestart ()
|
|
|
|
{
|
2007-07-03 20:04:11 +00:00
|
|
|
[ -e /var/lock/subsys/$prog ] && restart || return 0
|
2004-09-09 08:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 21:34:56 +00:00
|
|
|
case "$1" in
|
|
|
|
start|stop|restart|condrestart|try-restart|force-reload)
|
|
|
|
[ `id -u` != "0" ] && exit 4 ;;
|
|
|
|
esac
|
|
|
|
|
2004-09-09 08:24:56 +00:00
|
|
|
case "$1" in
|
2007-07-03 20:04:11 +00:00
|
|
|
start) start; RETVAL=$? ;;
|
|
|
|
stop) stop; RETVAL=$? ;;
|
2009-11-05 21:34:56 +00:00
|
|
|
status) status -p $PIDFILE $prog ; RETVAL=$? ;;
|
2007-07-03 20:04:11 +00:00
|
|
|
restart) restart; RETVAL=$? ;;
|
|
|
|
reload) RETVAL=3 ;;
|
2007-10-19 16:38:10 +00:00
|
|
|
condrestart|try-restart|force-reload) condrestart; RETVAL=$? ;;
|
2007-07-03 20:04:11 +00:00
|
|
|
*) usage ; RETVAL=2 ;;
|
2004-09-09 08:24:56 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|