#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when apcupsd
# We send an email message to root to notify him.
#

# detects doshutdown limit and bypass default action and NOT SHUTDOWN MASTER HOST!
# exit code 99 - apccontrol stops after this script, so no shutdown of this host. this is for testing purposes
# exit code 0  - apccontrol continues with shutdown after this script

WALL=wall
echo "MASTER UPS $1 doshutdown limit !!!!" | ${WALL}

HOSTNAME=`hostname`
MSG="$HOSTNAME UPS $1 doshutdown limit !!!! "
#
(
   echo "$MSG"
   echo " "
   /sbin/apcaccess status
) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN

exit 99