Blame SOURCES/mdmonitor.init

8fbece
#!/bin/bash
8fbece
# 
8fbece
# mdmonitor	This starts, stops, and reloads the mdadm-based
8fbece
#		software RAID monitoring and management facility
8fbece
#
8fbece
# chkconfig: 2345 15 85
8fbece
# description: software RAID monitoring and management
8fbece
# config: /etc/mdadm.conf
8fbece
#
8fbece
# Copyright 2002 Red Hat, Inc.
8fbece
#
8fbece
### BEGIN INIT INFO
8fbece
# Default-Start: 2 3 4 5
8fbece
# Default-Stop: 0 1 6
8fbece
# Short-Description: Start and stop the MD software RAID monitor
8fbece
# Description: The mdmonitor service checks the status of all software
8fbece
#	RAID arrays on the system.  In the event that any of the arrays
8fbece
#	transition into a degraded state, it notifies the system
8fbece
#	administrator.  Other options are available, see the mdadm.conf
8fbece
#	and mdadm man pages for possible ways to configure this service.
8fbece
### END INIT INFO
8fbece
8fbece
PIDPATH=/var/run/mdadm
8fbece
PIDFILE=/var/run/mdadm/mdadm.pid
8fbece
PATH=/sbin:/usr/sbin:$PATH
8fbece
RETVAL=0
8fbece
OPTIONS="--monitor --scan -f --pid-file=$PIDFILE"
8fbece
8fbece
prog=mdmonitor
8fbece
8fbece
# Source function library.
8fbece
. /etc/rc.d/init.d/functions
8fbece
8fbece
8fbece
usage ()
8fbece
{
8fbece
    echo "Usage: service $prog {start|stop|status|restart|try-restart|force-reload}"
8fbece
    RETVAL=1
8fbece
}
8fbece
8fbece
8fbece
start ()
8fbece
{
8fbece
# (Re)start mdmon to take over monitoring of mdmon started from the initrd
8fbece
    for i in /dev/md/*.pid; do
8fbece
	if [ -r $i ]; then
8fbece
            origprog="$prog"; prog="mdmon"
8fbece
            action $"Starting $prog: " /sbin/mdmon --takeover --all
8fbece
            prog="$origprog"
8fbece
	    break
8fbece
        fi
8fbece
    done
8fbece
# Make sure configuration file exists and has information we can use
8fbece
# MAILADDR or PROGRAM or both must be set in order to run mdadm --monitor
8fbece
    [ -f /etc/mdadm.conf ] || return 6
8fbece
    grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || return 6
8fbece
    # Create our directory if it isn't there yet
8fbece
    if [ ! -d $PIDPATH ]; then
8fbece
        mkdir -m 0700 $PIDPATH >&/dev/null
8fbece
	RC=$?
8fbece
	[ -x /sbin/restorecon ] && /sbin/restorecon $PIDPATH
8fbece
	if [ $RC -ne 0 ]; then
8fbece
	    echo -n "Failed to create /var/run/mdadm"
8fbece
            failure
8fbece
	    echo
8fbece
	    return 1
8fbece
	fi
8fbece
    fi
8fbece
    if [ -f "$PIDFILE" ]; then
8fbece
	checkpid `cat $PIDFILE` && return 0
8fbece
    fi
8fbece
    echo -n $"Starting $prog: "
8fbece
    cd /
8fbece
    daemon --user=root mdadm ${OPTIONS}
8fbece
    ret=$?
8fbece
    [ $ret -eq "0" ] && touch /var/lock/subsys/$prog
8fbece
    echo
8fbece
    return $ret
8fbece
}
8fbece
8fbece
stop ()
8fbece
{
8fbece
    [ -f /var/lock/subsys/$prog ] || return 0
8fbece
    echo -n "Killing $prog: "
8fbece
    killproc mdadm
8fbece
    echo
8fbece
    rm -f $PIDFILE
8fbece
    rm -f /var/lock/subsys/$prog
8fbece
}
8fbece
8fbece
restart ()
8fbece
{
8fbece
    stop
8fbece
    start
8fbece
}
8fbece
8fbece
condrestart ()
8fbece
{
8fbece
    [ -e /var/lock/subsys/$prog ] && restart || return 0
8fbece
}
8fbece
8fbece
8fbece
case "$1" in
8fbece
    start|stop|restart|condrestart|try-restart|force-reload)
8fbece
    	[ `id -u` != "0" ] && exit 4 ;;
8fbece
esac
8fbece
8fbece
case "$1" in
8fbece
    start) start; RETVAL=$? ;;
8fbece
    stop) stop; RETVAL=$? ;;
8fbece
    status) status -p $PIDFILE $prog ; RETVAL=$? ;;
8fbece
    restart) restart; RETVAL=$? ;;
8fbece
    reload) RETVAL=3 ;;
8fbece
    condrestart|try-restart|force-reload) condrestart; RETVAL=$? ;;
8fbece
    *) usage ; RETVAL=2 ;;
8fbece
esac
8fbece
8fbece
exit $RETVAL