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.
|
|
|
|
|
|
|
|
PATH=/sbin:/usr/sbin:$PATH
|
|
|
|
RETVAL=0
|
|
|
|
|
|
|
|
prog=mdmonitor
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# 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 ] || exit 0
|
|
|
|
grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || exit 0
|
|
|
|
|
|
|
|
|
|
|
|
usage ()
|
|
|
|
{
|
|
|
|
echo "Usage: service $prog {start|stop|status|restart|condrestart}"
|
|
|
|
RETVAL=1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
start ()
|
|
|
|
{
|
|
|
|
ulimit -S -c 0 >/dev/null 2>&1
|
|
|
|
echo -n $"Starting $prog: "
|
2004-09-09 08:27:45 +00:00
|
|
|
daemon --check mdadm \
|
|
|
|
"/bin/bash -c \"mdadm --monitor --scan -f > /var/run/mdadm.pid\""
|
2004-09-09 08:24:56 +00:00
|
|
|
# hack: wait for mdadm to die, assume success if it doesn't die quickly
|
|
|
|
usleep 100000
|
2004-09-09 08:27:45 +00:00
|
|
|
if [ -s /var/run/mdadm.pid -a -d /proc/$(cat /var/run/mdadm.pid) ] ; then
|
2004-09-09 08:24:56 +00:00
|
|
|
success $"mdadm"
|
|
|
|
RETVAL=0
|
2004-09-09 08:27:45 +00:00
|
|
|
touch /var/lock/subsys/$prog
|
2004-09-09 08:24:56 +00:00
|
|
|
else
|
|
|
|
failure $"mdadm"
|
2004-09-09 08:27:45 +00:00
|
|
|
rm -f /var/run/mdadm.pid
|
|
|
|
rm -f /var/lock/subsys/$prog
|
2004-09-09 08:24:56 +00:00
|
|
|
RETVAL=1
|
|
|
|
fi
|
2004-09-09 08:27:45 +00:00
|
|
|
echo
|
2004-09-09 08:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop ()
|
|
|
|
{
|
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/run/mdadm.pid
|
|
|
|
rm -f /var/lock/subsys/$prog
|
|
|
|
}
|
|
|
|
|
|
|
|
restart ()
|
|
|
|
{
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
condrestart ()
|
|
|
|
{
|
|
|
|
[ -e /var/lock/subsys/$prog ] && restart
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start) start ;;
|
|
|
|
stop) stop ;;
|
|
|
|
status) status mdadm ;;
|
|
|
|
restart|reload) restart ;;
|
|
|
|
condrestart) condrestart ;;
|
|
|
|
*) usage ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|