#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the    
# UPS goes back on to the mains after a power failure.
# We send an email message to root to notify him.
#
SYSADMIN=root
MAIL="/bin/mail"

HOSTNAME=`hostname`
OUTF="/tmp/apcupsd.mainsback.$$"
MSG="$HOSTNAME Power has returned"
#
echo "$MSG" >$OUTF  
echo " " >>$OUTF
/sbin/apcaccess status >>$OUTF
cat $OUTF | $MAIL -s "$MSG" $SYSADMIN
rm -f $OUTF
exit 0
