[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | # Syn-3 apc control file. (C)DatuX |
---|
| 3 | # Using original apccontrol script as a guideline. |
---|
| 4 | |
---|
| 5 | APCPID=/var/run/apcupsd.pid |
---|
| 6 | APCUPSD=/sbin/apcupsd |
---|
| 7 | SHUTDOWN=/sbin/shutdown |
---|
| 8 | WALL=wall |
---|
| 9 | |
---|
| 10 | # Call syn3-apccheck status poller. |
---|
| 11 | # We dont use the events below, because events like commok could overwrite more imporant things like onbattery. |
---|
| 12 | syn3-apccheck &>/dev/null |
---|
| 13 | |
---|
| 14 | # Do default operations (from original apccontrol file) |
---|
| 15 | case "$1" in |
---|
| 16 | killpower) |
---|
| 17 | echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" |
---|
| 18 | sleep 10 |
---|
| 19 | ${APCUPSD} --killpower |
---|
| 20 | echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL} |
---|
| 21 | ;; |
---|
| 22 | commfailure) |
---|
| 23 | #NO: this is annoying if you dont have an UPS |
---|
| 24 | #echo "Warning communications lost with UPS ${2}" | ${WALL} |
---|
| 25 | ;; |
---|
| 26 | commok) |
---|
| 27 | echo "Communications restored with UPS ${2}" | ${WALL} |
---|
| 28 | ;; |
---|
| 29 | # |
---|
| 30 | # powerout, onbattery, offbattery, mainsback events occur |
---|
| 31 | # in that order. |
---|
| 32 | # |
---|
| 33 | powerout) |
---|
| 34 | ;; |
---|
| 35 | onbattery) |
---|
| 36 | echo "Power failure on UPS ${2}. Running on batteries." | ${WALL} |
---|
| 37 | ;; |
---|
| 38 | offbattery) |
---|
| 39 | echo "Power has returned on UPS ${2}..." | ${WALL} |
---|
| 40 | ;; |
---|
| 41 | mainsback) |
---|
| 42 | if [ -f /etc/powerfail ] ; then |
---|
| 43 | echo "Continuing with shutdown." | ${WALL} |
---|
| 44 | fi |
---|
| 45 | ;; |
---|
| 46 | failing) |
---|
| 47 | echo "Battery power exhaused on UPS ${2}. Doing shutdown." | ${WALL} |
---|
| 48 | ;; |
---|
| 49 | timeout) |
---|
| 50 | echo "Battery time limit exceeded on UPS ${2}. Doing shutdown." | ${WALL} |
---|
| 51 | ;; |
---|
| 52 | loadlimit) |
---|
| 53 | echo "Remaining battery charge below limit on UPS ${2}. Doing shutdown." | ${WALL} |
---|
| 54 | ;; |
---|
| 55 | runlimit) |
---|
| 56 | echo "Remaining battery runtime below limit on UPS ${2}. Doing shutdown." | ${WALL} |
---|
| 57 | ;; |
---|
| 58 | doreboot) |
---|
| 59 | echo "UPS ${2} initiating Reboot Sequence" | ${WALL} |
---|
| 60 | ${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot" |
---|
| 61 | ;; |
---|
| 62 | doshutdown) |
---|
| 63 | echo "UPS ${2} initiated Shutdown Sequence" | ${WALL} |
---|
| 64 | ${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown" |
---|
| 65 | ;; |
---|
| 66 | annoyme) |
---|
| 67 | echo "Power problems with UPS ${2}. Please logoff." | ${WALL} |
---|
| 68 | ;; |
---|
| 69 | emergency) |
---|
| 70 | echo "Emergency Shutdown. Possible battery failure on UPS ${2}." | ${WALL} |
---|
| 71 | ;; |
---|
| 72 | changeme) |
---|
| 73 | echo "Emergency! Batteries have failed on UPS ${2}. Change them NOW" | ${WALL} |
---|
| 74 | ;; |
---|
| 75 | remotedown) |
---|
| 76 | echo "Remote Shutdown. Beginning Shutdown Sequence." | ${WALL} |
---|
| 77 | ;; |
---|
| 78 | startselftest) |
---|
| 79 | ;; |
---|
| 80 | endselftest) |
---|
| 81 | ;; |
---|
| 82 | battdetach) |
---|
| 83 | ;; |
---|
| 84 | battattach) |
---|
| 85 | ;; |
---|
| 86 | *) echo "Usage: ${0##*/} command" |
---|
| 87 | echo " warning: this script is intended to be launched by" |
---|
| 88 | echo " apcupsd and should never be launched by users." |
---|
| 89 | exit 1 |
---|
| 90 | ;; |
---|
| 91 | esac |
---|
| 92 | |
---|