#!/bin/sh
# apcupsd: kill power via UPS (if powerfail situation)
# (Originally from Fedora.)

# See if this is a powerfail situation.
faildir=$(grep -e^PWRFAILDIR /etc/apcupsd/apcupsd.conf)
faildir="${faildir#PWRFAILDIR }"

if [ -f "${faildir:=/etc/apcupsd}/powerfail" ]; then
  echo
  echo "APCUPSD will now power off the UPS"
  echo
  /etc/apcupsd/apccontrol killpower
fi
