#!/bin/sh
# NUT ups model-specific drivers start-up and shutdown script.
# This should be started before rc.nut-upsd on the machine connected to the
# UPS's control port. See /etc/nut/ for configuration files.

# Start upsdrvctl:
upsdrvctl_start() {
  # Make sure the runtime directory is there:
  mkdir -p /run/nut
  chown -R nut:nut /run/nut
  chmod 0770 /run/nut
  # Load NUT driver(s):
  echo "Starting the NUT UPS driver controller:  upsdrvctl -u nut start"
  upsdrvctl -u nut start
}

# Stop upsdrvctl:
upsdrvctl_stop() {
  echo "Stopping the NUT UPS driver controller."
  upsdrvctl stop
}

case "$1" in
'start')
  upsdrvctl_start
  ;;
'stop')
  upsdrvctl_stop
  ;;
*)
  echo "usage $0 start|stop"
esac
