#!/bin/sh
#
# upsmon	NUT daemon monitoring tool
#
# chkconfig:	2345 10 90
#
# description:	upsmon talks to upsd and notifies of ups status changes,
#               also shutting systems down if required.
# processname:	upsmon
# config:	/etc/ups/

# Source function library.
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Get config.
[ -f /etc/sysconfig/upsmon ] && . /etc/sysconfig/upsmon

# See how we are called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/upsmon ]; then
		msg_starting "UPSmon"
		daemon upsmon
		[ "$?" -eq 0 ] && touch /var/lock/subsys/upsmon
	else
		msg_Already_Running "UPSmon"
	fi
	;;
  stop)
  	if [ -f /var/lock/subsys/upsmon ]; then
		msg_stopping "UPSmon"
		killproc upsmon
		rm -f /var/lock/subsys/upsmon
	else
		msg_Not_Running "UPS daemon"
	fi
	;;
  restart)
	$0 stop
	$0 start
	;;
  force-reload)
	$0 restart
	exit $?
	;;
  status)
	status upsmon
	exit $?
	;;
  *)
	msg_Usage "$0 {start|stop|status|restart|reload|force-reload}"
	exit 1
	;;
esac 
