File apcupsd-powersave.patch of Package apcupsd
--- examples/safe.apccontrol.in
+++ examples/safe.apccontrol.in
@@ -15,60 +15,80 @@
#
case "$1" in
killpower)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: ${APCUPSD} --killpower would have been."
wall <<EOF
apccontrol: ${APCUPSD} --killpower would have been.
EOF
;;
commfailure)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Warning serial port communications with UPS lost."
wall <<EOF
apccontrol: Warning serial port communications with UPS lost.
EOF
;;
commok)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Serial communciations with UPS restored."
wall <<EOF
apccontrol: Serial communciations with UPS restored.
EOF
;;
powerout)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Warning power loss detected."
wall <<EOF
apccontrol: Warning power loss detected.
EOF
;;
onbattery)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Power failure. Running on UPS batteries."
wall <<EOF
apccontrol: Power failure. Running on UPS batteries.
EOF
;;
offbattery)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Off battery. Mains returned."
wall <<EOF
apccontrol: Off battery. Mains returned.
EOF
;;
failing)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery power exhaused. Doing shutdown."
wall <<EOF
apccontrol: UPS battery power exhaused. Doing shutdown.
EOF
;;
timeout)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery runtime limit exceeded. Doing shutdown."
wall <<EOF
apccontrol: UPS battery runtime limit exceeded. Doing shutdown.
EOF
;;
loadlimit)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery discharge limit reached. Doing shutdown."
wall <<EOF
apccontrol: UPS battery discharge limit reached. Doing shutdown.
EOF
;;
runlimit)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery runtime percent reached. Doing shutdown."
wall <<EOF
apccontrol: UPS battery runtime percent reached. Doing shutdown.
@@ -81,30 +101,40 @@
EOF
;;
doshutdown)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for halt would have been called."
wall <<EOF
apccontrol: ${SHUTDOWN} for halt would have been called.
EOF
;;
mainsback)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Power has returned..."
wall <<EOF
apccontrol: Power has returned...
EOF
;;
annoyme)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Power problems please logoff."
wall <<EOF
apccontrol: Power problems please logoff.
EOF
;;
emergency)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for emergency halt would have been called."
wall <<EOF
apccontrol: ${SHUTDOWN} for emergency halt would have been called.
EOF
;;
changeme)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: Emergency! UPS batteries have failed."
wall <<EOF
apccontrol: Emergency! UPS batteries have failed.
@@ -112,18 +142,24 @@
EOF
;;
remotedown)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for remote halt would have been called."
wall <<EOF
apccontrol: ${SHUTDOWN} for remote halt would have been called.
EOF
;;
startselftest)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: start self test would have been called."
wall <<EOF
apccontrol: start self test would have been called.
EOF
;;
endselftest)
+ /usr/lib/powersave/powersave-notify \
+"apccontrol: end self test would have been called."
wall <<EOF
apccontrol: end self test would have been called.
--- platforms/apccontrol.in
+++ platforms/apccontrol.in
@@ -24,6 +24,7 @@
SCRIPTSHELL=@SCRIPTSHELL@
SCRIPTDIR=@sysconfdir@
WALL=wall
+NOTIFY=/usr/lib/powersave/powersave-notify
#
# Concatenate all output from this script to the events file
@@ -56,18 +57,23 @@
fi
fi
+function notify() {
+ ${NOTIFY} "$1"
+ echo "$1" | ${WALL}
+}
+
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}
+ notify "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}"
;;
commfailure)
- echo "Warning communications lost with UPS ${2}" | ${WALL}
+ notify "Warning communications lost with UPS ${2}"
;;
commok)
- echo "Communications restored with UPS ${2}" | ${WALL}
+ notify "Communications restored with UPS ${2}"
;;
#
# powerout, onbattery, offbattery, mainsback events occur
@@ -76,10 +82,10 @@
powerout)
;;
onbattery)
- echo "Power failure on UPS ${2}. Running on batteries." | ${WALL}
+ notify "Power failure on UPS ${2}. Running on batteries."
;;
offbattery)
- echo "Power has returned on UPS ${2}..." | ${WALL}
+ notify "Power has returned on UPS ${2}..."
;;
mainsback)
if [ -f @PWRFAILDIR@/powerfail ] ; then
@@ -87,36 +93,36 @@
fi
;;
failing)
- echo "Battery power exhaused on UPS ${2}. Doing shutdown." | ${WALL}
+ notify "Battery power exhaused on UPS ${2}. Doing shutdown."
;;
timeout)
- echo "Battery time limit exceeded on UPS ${2}. Doing shutdown." | ${WALL}
+ notify "Battery time limit exceeded on UPS ${2}. Doing shutdown."
;;
loadlimit)
- echo "Remaining battery charge below limit on UPS ${2}. Doing shutdown." | ${WALL}
+ notify "Remaining battery charge below limit on UPS ${2}. Doing shutdown."
;;
runlimit)
- echo "Remaining battery runtime below limit on UPS ${2}. Doing shutdown." | ${WALL}
+ notify "Remaining battery runtime below limit on UPS ${2}. Doing shutdown."
;;
doreboot)
- echo "UPS ${2} initiating Reboot Sequence" | ${WALL}
+ notify "UPS ${2} initiating Reboot Sequence"
${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot"
;;
doshutdown)
- echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
+ notify "UPS ${2} initiated Shutdown Sequence"
${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
;;
annoyme)
- echo "Power problems with UPS ${2}. Please logoff." | ${WALL}
+ notify "Power problems with UPS ${2}. Please logoff."
;;
emergency)
- echo "Emergency Shutdown. Possible battery failure on UPS ${2}." | ${WALL}
+ notify "Emergency Shutdown. Possible battery failure on UPS ${2}."
;;
changeme)
- echo "Emergency! Batteries have failed on UPS ${2}. Change them NOW" | ${WALL}
+ notify "Emergency! Batteries have failed on UPS ${2}. Change them NOW"
;;
remotedown)
- echo "Remote Shutdown. Beginning Shutdown Sequence." | ${WALL}
+ notify "Remote Shutdown. Beginning Shutdown Sequence."
;;
startselftest)
;;