#!/usr/bin/sh # # Copyright (C) 1999-2000 Riccardo Facchetti # # Generated automatically from apccontrol.sh.in by configure. # # Apccontrol for Sun Solaris provided by Carl Erhorn # # These variables are needed for set up the autoconf other variables. # Updated October 7th, 2001 - CPE # prefix=/usr/pkg exec_prefix=${prefix} APCPID=/var/run/apcupsd.pid APCUPSD=/usr/pkg/sbin/apcupsd SHUTDOWN=/usr/sbin/shutdown SCRIPTSHELL=/usr/bin/sh SCRIPTDIR=/usr/pkg/etc/apcupsd POWERFAILDIR=/etc # # This piece is to substitute the default behaviour with your own script, # perl, or C program. # You can customize every single command creating an executable file (may be a # script or a compiled program) and calling it the same as the $1 parameter # passed by apcupsd to this script. # # After executing your script, apccontrol continues with the default action. # If you do not want apccontrol to continue, exit your script with exit # code 99. E.g. "exit 99". # # WARNING: the apccontrol file will be overwritten every time you update your # apcupsd, doing `make install'. Your own customized scripts will _not_ be # overwritten. If you wish to make changes to this file (discouraged), you # should change apccontrol.sh.in and then rerun the configure process. # if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ] then ${SCRIPTDIR}/${1} ${2} ${3} ${4} # exit code 99 means he does not want us to do default action if [ $? = 99 ] ; then exit 0 fi fi case "$1" in killpower) ${APCUPSD} --killpower ;; commfailure) printf "Warning serial port communications with UPS lost." | wall -a ;; commok) printf "Serial communciations with UPS restored." | wall -a ;; powerout) printf "Warning power loss detected." | wall -a ;; onbattery) printf "Power failure. Running on UPS batteries." | wall -a ;; failing) printf "UPS battery power exhaused. Doing shutdown.\n" | wall -a ;; timeout) printf "UPS battery runtime limit exceded. Doing shutdown.\n" | wall -a ;; loadlimit) printf "UPS battery discharge limit reached. Doing shutdown.\n" | wall -a ;; runlimit) printf "UPS battery runtime percent reached. Doing shutdown.\n" \ | wall -a ;; doreboot) printf "Beginning Reboot Sequence" | wall -a ${SHUTDOWN} -y -g0 -i6 "apcupsd initiated reboot" ;; doshutdown) printf "Beginning Shutdown Sequence" | wall -a ${SHUTDOWN} -y -g0 -i0 "apcupsd initiated shutdown" ;; mainsback) printf "Power has returned..." | wall -a ;; annoyme) printf "Power problems please logoff." | wall -a ;; emergency) printf "Emergency Shutdown. Possible UPS battery failure." \ | wall -a ${SHUTDOWN} -y -g0 -i0 "apcupsd emergency shutdown" ;; changeme) printf "Emergency! UPS batteries have failed\nChange them NOW" \ | wall -a ;; remotedown) printf "Remote Shutdown.\nBeginning Shutdown Sequence." | wall -a ${SHUTDOWN} -y -g0 -i0 "apcupsd remote shutdown" ;; restartme) echo -n "Restarting APCUPSD Power Management: " THEPID=`cat ${APCPID}` kill ${THEPID} rm -f ${APCPID} rm -f ${PWRFAILDIR}/powerfail `${APCUPSD}` echo "apcupsd" ;; startselftest) ;; endselftest) ;; mastertimeout) printf "Warning connection to master lost." | wall -a ;; masterconnect) printf "Connection to master established." | wall -a ;; *) echo "Usage: ${0##*/} command" echo " warning: this script is intended to be launched by" echo " apcupsd and should never be launched by users." exit 1 ;; esac