123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #!/bin/sh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- prefix=/usr
- exec_prefix=/usr
-
- APCPID=/var/run/apcupsd.pid
- APCUPSD=/usr/sbin/apcupsd
- SHUTDOWN=/sbin/shutdown
- SCRIPTSHELL=/bin/sh
- SCRIPTDIR=/etc/apcupsd
- WALL=true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ]
- then
- ${SCRIPTDIR}/${1} ${2} ${3} ${4}
-
- if [ $? = 99 ] ; then
- exit 0
- fi
- fi
-
- case "$1" in
- killpower)
- echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}"
- sleep 10
- ${APCUPSD} --killpower
- echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
- ;;
- commfailure)
- echo "Warning communications lost with UPS ${2}" | ${WALL}
- ;;
- commok)
- echo "Communications restored with UPS ${2}" | ${WALL}
- ;;
-
-
-
-
- powerout)
- echo "Warning power loss detected on UPS ${2}" | ${WALL}
- ;;
- onbattery)
- echo "Power failure on UPS ${2}. Running on batteries." | ${WALL}
- ;;
- offbattery)
- ;;
- mainsback)
- echo "Power has returned on UPS ${2}..." | ${WALL}
- if [ -f /etc/powerfail ] ; then
- printf "Continuing with shutdown." | ${WALL}
- fi
- ;;
- failing)
- echo "Battery power exhaused on UPS ${2}. Doing shutdown." | ${WALL}
- ;;
- timeout)
- echo "Battery time limit exceeded on UPS ${2}. Doing shutdown." | ${WALL}
- ;;
- loadlimit)
- echo "Remaining battery charge below limit on UPS ${2}. Doing shutdown." | ${WALL}
- ;;
- runlimit)
- echo "Remaining battery runtime below limit on UPS ${2}. Doing shutdown." | ${WALL}
- ;;
- doreboot)
- echo "UPS ${2} initiating Reboot Sequence" | ${WALL}
- ${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot"
- ;;
- doshutdown)
- echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
- ${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
- ;;
- annoyme)
- echo "Power problems with UPS ${2}. Please logoff." | ${WALL}
- ;;
- emergency)
- echo "Emergency Shutdown. Possible battery failure on UPS ${2}." | ${WALL}
- ;;
- changeme)
- echo "Emergency! Batteries have failed on UPS ${2}. Change them NOW" | ${WALL}
- ;;
- remotedown)
- echo "Remote Shutdown. Beginning Shutdown Sequence." | ${WALL}
- ;;
- restartme)
- echo -n "Restarting APCUPSD Power Management: "
- THEPID=`cat ${APCPID}`
- kill ${THEPID}
- rm -f ${APCPID}
- rm -f /etc/powerfail
- rm -f /etc/nologin
- sleep 5
- `${APCUPSD}`
- echo "apcupsd"
- ;;
- startselftest)
- ;;
- endselftest)
- ;;
- battdetach)
- ;;
- battattach)
- ;;
- *) 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
|