93b483ae63
Summary of changes since 3.8.6: * Support for USB UPSe (not enabled in pkgsrc) * new networking driver (net) that uses the NIS interface rather than the older master/slave networking * The apctest program has been enhanced to do EEPROM programming in a much more interactive way than the prior versions. * Added a ONBATTERYDELAY config, time to switch to onbattery state after a power failure. New event "offbattery", which is the same as mainsback but only sent if we got to state onbattery * new snmp driver, with trap support. * Battery disconnect and reconnect events
152 lines
4.8 KiB
Text
152 lines
4.8 KiB
Text
$NetBSD: patch-ad,v 1.4 2006/11/15 21:46:25 bouyer Exp $
|
|
|
|
--- /dev/null 2006-11-15 17:26:11.000000000 +0100
|
|
+++ platforms/netbsd/apccontrol.in 2006-11-15 17:42:37.000000000 +0100
|
|
@@ -0,0 +1,147 @@
|
|
+#!@SCRIPTSHELL@
|
|
+#
|
|
+# Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
|
|
+#
|
|
+# for apcupsd release @VERSION@ (@DATE@) - @DISTNAME@
|
|
+#
|
|
+# @configure_input@
|
|
+#
|
|
+
|
|
+#
|
|
+# These variables are needed for set up the autoconf other variables.
|
|
+#
|
|
+prefix=@prefix@
|
|
+exec_prefix=@exec_prefix@
|
|
+
|
|
+APCPID=@PIDDIR@/apcupsd.pid
|
|
+APCUPSD=@sbindir@/apcupsd
|
|
+SHUTDOWN=@SHUTDOWN@
|
|
+SCRIPTSHELL=@SCRIPTSHELL@
|
|
+SCRIPTDIR=@sysconfdir@
|
|
+
|
|
+#
|
|
+# 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)
|
|
+ printf "UPS now committed to shut down" | wall
|
|
+# echo "Apccontrol doing: ${APCUPSD} --killpower"
|
|
+# sleep 10
|
|
+# ${APCUPSD} --killpower
|
|
+ ;;
|
|
+ commfailure)
|
|
+ printf "Communications with UPS lost." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Warning serial port communications with UPS lost."
|
|
+ ;;
|
|
+ commok)
|
|
+ printf "Communciations with UPS restored." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Communciations with UPS restored."
|
|
+ ;;
|
|
+ powerout)
|
|
+ printf "Warning power loss detected." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Warning power loss detected."
|
|
+ ;;
|
|
+ onbattery)
|
|
+ printf "Power failure. Running on UPS batteries." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Power failure. Running on UPS batteries."
|
|
+ ;;
|
|
+ offbattery)
|
|
+ ;;
|
|
+ mainsback)
|
|
+ printf "Power has returned..." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Power has returned..."
|
|
+ if [ -f @PWRFAILDIR@/powerfail ] ; then
|
|
+ printf "Continuing with shutdown." | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Continuing with shutdown."
|
|
+ fi
|
|
+ ;;
|
|
+ failing)
|
|
+ printf "UPS battery power exhaused. Doing shutdown.\n" | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "UPS battery power exhaused. Doing shutdown.\n"
|
|
+ ;;
|
|
+ timeout)
|
|
+ printf "UPS battery runtime limit exceeded. Doing shutdown.\n" | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "UPS battery runtime limit exceeded. Doing shutdown.\n"
|
|
+ ;;
|
|
+ loadlimit)
|
|
+ printf "UPS battery discharge limit reached. Doing shutdown.\n" | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "UPS battery discharge limit reached. Doing shutdown.\n"
|
|
+ ;;
|
|
+ runlimit)
|
|
+ printf "UPS battery runtime percent reached. Doing shutdown.\n" \
|
|
+ | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "UPS battery runtime percent reached. Doing shutdown.\n"
|
|
+ ;;
|
|
+ doreboot)
|
|
+ printf "Beginning Reboot Sequence" | wall
|
|
+ ${SHUTDOWN} -r now "apcupsd initiated reboot"
|
|
+ ;;
|
|
+ doshutdown)
|
|
+ printf "Beginning Shutdown Sequence" | wall
|
|
+ ${SHUTDOWN} -h now "apcupsd initiated shutdown"
|
|
+ ;;
|
|
+ annoyme)
|
|
+ printf "Power problems please logoff." | wall
|
|
+ ;;
|
|
+ emergency)
|
|
+ printf "Emergency Shutdown. Possible UPS battery failure." \
|
|
+ | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Emergency Shutdown. Possible UPS battery failure."
|
|
+ ${SHUTDOWN} -h now "apcupsd emergency shutdown"
|
|
+ ;;
|
|
+ changeme)
|
|
+ printf "Emergency! UPS batteries have failed\nChange them NOW" \
|
|
+ | wall
|
|
+ /usr/bin/logger -p user.info -t apccontrol "Emergency! UPS batteries have failed\nChange them NOW"
|
|
+ ;;
|
|
+ remotedown)
|
|
+ printf "Remote Shutdown.\nBeginning Shutdown Sequence." | wall
|
|
+ ${SHUTDOWN} -h now "apcupsd remote shutdown"
|
|
+ ;;
|
|
+ restartme)
|
|
+ echo -n "Restarting APCUPSD Power Management: "
|
|
+ THEPID=`cat ${APCPID}`
|
|
+ kill ${THEPID}
|
|
+ rm -f ${APCPID}
|
|
+ rm -f @PWRFAILDIR@/powerfail
|
|
+ rm -f @nologdir@/nologin
|
|
+ sleep 5
|
|
+ `${APCUPSD} --kill-on-powerfail`
|
|
+ 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
|