#!/bin/sh
# Start/stop/restart upsmon.

# Start upsmon:
upsmon_start() {
  if [ -x /opt/upsmon ]; then
    echo "Starting upsmon daemon:  /opt/upsmon/upsagent"
    /opt/upsmon/upsagent
  fi
}

# Stop upsmon:
upsmon_stop() {
  killall upsagent
}

# Restart supsmon:
upsmon_restart() {
  upsmon_stop
  sleep 1
  upsmon_start
}

case "$1" in
'start')
  upsmon_start
  ;;
'stop')
  upsmon_stop
  ;;
'restart')
  upsmon_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac
