5c2cefb
#!/bin/sh
9ad6e7b
#
5c2cefb
# /etc/init.d/munin-node
9ad6e7b
#
5c2cefb
# chkconfig: - 90 10
5c2cefb
# description: Network-wide resource monitoring tool (node)
9ad6e7b
# processname: munin-node
5c2cefb
#
5c2cefb
### BEGIN INIT INFO
5c2cefb
# Provides: munin-node
5c2cefb
# Required-Start: $network $syslog
5c2cefb
# Required-Stop:
5c2cefb
# Default-Stop: 0 1 2 6
5c2cefb
# Short-Description: Network-wide resource monitoring tool (node)
5c2cefb
# Description: Munin is a highly flexible and powerful solution used to create
5c2cefb
#	graphs of virtually everything imaginable throughout your network,
5c2cefb
#	while still maintaining a rattling ease of installation and
5c2cefb
#	configuration.
5c2cefb
### END INIT INFO
9ad6e7b
9ad6e7b
# Source function library.
5c2cefb
. /etc/init.d/functions
9ad6e7b
5c2cefb
# Source networking configuration.
5c2cefb
. /etc/sysconfig/network
9ad6e7b
5c2cefb
# Check that networking is up.
5c2cefb
[ ${NETWORKING} = "no" ] && exit 0
9ad6e7b
5c2cefb
# Read config
5c2cefb
ASYNCD=no
5c2cefb
[ -f /etc/sysconfig/munin-node ] && . /etc/sysconfig/munin-node
5c2cefb
5c2cefb
prognode=munin-node
5c2cefb
progasync=munin-asyncd
5c2cefb
binnode=/usr/sbin/$prognode
5c2cefb
binasync=/usr/sbin/$progasync
5c2cefb
pidnode=/var/run/munin/$prognode.pid
5c2cefb
RETVAL=0
5c2cefb
5c2cefb
start() {
5c2cefb
    echo -n $"Starting $prognode: "
5c2cefb
    mkdir -p /var/run/munin 2>/dev/null
5c2cefb
    chown munin:munin /var/run/munin
5c2cefb
    restorecon /var/run/munin 2>/dev/null
5c2cefb
    ${binnode} < /dev/null > /dev/null 2>&1 &
5c2cefb
    sleep 1
5c2cefb
    pkill -0 $prognode
5c2cefb
    RETVAL=$?
5c2cefb
    if [ $RETVAL -eq 0 ]; then
5c2cefb
	echo_success
5c2cefb
	touch /var/lock/subsys/$prognode
5c2cefb
	if [ "${ASYNCD}" = "yes" ]; then
5c2cefb
	    echo
5c2cefb
	    echo -n $"Starting $progasync: "
5c2cefb
	    sleep 1
5c2cefb
	    ${binasync} < /dev/null > /dev/null 2>&1 &
5c2cefb
	    sleep 1
5c2cefb
	    pkill -0 $progasync
5c2cefb
	    RETVAL=$?
5c2cefb
	    if [ $RETVAL -eq 0 ]; then
9ad6e7b
		echo_success
5c2cefb
	    else
9ad6e7b
		echo_failure
5c2cefb
	    fi
9ad6e7b
	fi
5c2cefb
    else
5c2cefb
	echo_failure
5c2cefb
    fi
5c2cefb
    echo
5c2cefb
    return $RETVAL
5c2cefb
}
5c2cefb
5c2cefb
stop() {
5c2cefb
    if [ "${ASYNCD}" = "yes" ]; then
5c2cefb
	echo -n $"Stopping $progasync: "
5c2cefb
	killproc ${binasync}
9ad6e7b
	echo
5c2cefb
    fi
5c2cefb
    echo -n $"Stopping $prognode: "
5c2cefb
    killproc ${binnode}
5c2cefb
    RETVAL=$?
5c2cefb
    echo
5c2cefb
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prognode
5c2cefb
    return $RETVAL
5c2cefb
}
5c2cefb
5c2cefb
restart() {
5c2cefb
    stop
5c2cefb
    start
5c2cefb
}
5c2cefb
5c2cefb
# See how we were called.
5c2cefb
case "$1" in
5c2cefb
    start)
5c2cefb
	start
9ad6e7b
	;;
5c2cefb
    stop)
5c2cefb
	stop
9ad6e7b
	;;
5c2cefb
    restart)
5c2cefb
	restart
9ad6e7b
	;;
5c2cefb
    condrestart)
5c2cefb
	[ -f /var/lock/subsys/$prognode ] && restart
5c2cefb
	;;
5c2cefb
    status)
5c2cefb
	status -p ${pidnode} ${binnode}
9ad6e7b
	RETVAL=$?
5c2cefb
	if [ $RETVAL = 0 -a "${ASYNCD}" = "yes" ]; then
5c2cefb
	    status ${binasync}
5c2cefb
	    RETVAL=$?
5c2cefb
	fi
9ad6e7b
	;;
5c2cefb
    *)
5c2cefb
	echo "Usage: $0 {start|stop|restart|condrestart|status}"
5c2cefb
	RETVAL=2
9ad6e7b
esac
9ad6e7b
9ad6e7b
exit $RETVAL