#!/bin/sh

. "`dirname $0`/rcdefs"

case "$1" in
  start)
	Print -n "Starting Smart UPS monitoring... "
	if [ "${UPS_MODE}" = "master" ]
	then
		${UPS_BIN}/${UPS_DRIVER} ${UPS_DEVICE}
		${UPS_BIN}/upsd
		${UPS_BIN}/upslog localhost ${UPS_LOG}
	fi
	${UPS_BIN}/upsmon ${UPS_OPTIONS} ${UPS_MODE}
	Print "done."
	;;
  stop)
	Print -n "Stopping Smart UPS monitoring... "
	Terminate upsmon
	if [ "${UPS_MODE}" = "master" ]
	then
		Terminate upslog
		Terminate upsd
		Terminate ${UPS_DRIVER}
	fi
	Print "done."
	;;
  *)
	Usage "$0"
	exit 1
esac

exit 0
