Blame SOURCES/mdmonitor.init

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