#!/bin/sh
#
# munin-cgi-graph Start and stop Munin FastCGI processes for NGINX
#
# chkconfig: - 80 20
# description: Spawn Munin FastCGI scripts to be used by NGINX web server
### BEGIN INIT INFO
# Provides:
# Required-Start: $network $syslog
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop: 0 1 2 6
# Short-Description: Start and stop Munin FastCGI processes
# Description: Spawn Munin FastCGI scripts to be used by NGINX web server
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
exec=/usr/bin/spawn-fcgi
lockfile=/var/lock/subsys/munin-cgi-graph
graphprog=/var/www/html/munin/cgi/munin-cgi-graph
graphsock=/var/run/munin/munin-cgi-graph.sock
graphpid=/var/run/munin/munin-cgi-graph.pid
GRAPHOPTIONS="-u munin -U nginx -S -M 0600 -F 2"
[ -f /etc/sysconfig/munin-cgi-graph ] && . /etc/sysconfig/munin-cgi-graph
munin_cleanup() {
# Remove the socket if it exists
[ -n "${graphsock}" -a -S "${graphsock}" ] && rm -f ${graphsock}
}
start() {
munin_cleanup
echo -n $"Starting munin-cgi-graph: "
daemon "${exec} -s ${graphsock} -P ${graphpid} ${GRAPHOPTIONS} -- ${graphprog} >/dev/null"
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
touch $lockfile
fi
return $RETVAL
}
stop() {
echo -n $"Stopping munin-cgi-graph: "
killproc $graphprog
RETVAL=$?
echo
munin_cleanup
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}
restart() {
stop
start
}
reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $graphprog
}
rh_status_q() {
rh_status &>/dev/null
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload}"
exit 2
esac
exit $?