3 # Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
5 # for apcupsd release @VERSION@ (@DATE@) - @DISTNAME@
11 # These variables are needed for set up the autoconf other variables.
14 exec_prefix=@exec_prefix@
16 APCPID=@PIDDIR@/apcupsd.pid
17 APCUPSD=@sbindir@/apcupsd
19 SCRIPTSHELL=@SCRIPTSHELL@
20 SCRIPTDIR=@sysconfdir@
23 # This piece is to substitute the default behaviour with your own script,
25 # You can customize every single command creating an executable file (may be a
26 # script or a compiled program) and calling it the same as the $1 parameter
27 # passed by apcupsd to this script.
29 # After executing your script, apccontrol continues with the default action.
30 # If you do not want apccontrol to continue, exit your script with exit
31 # code 99. E.g. "exit 99".
33 # WARNING: the apccontrol file will be overwritten every time you update your
34 # apcupsd, doing `make install'. Your own customized scripts will _not_ be
35 # overwritten. If you wish to make changes to this file (discouraged), you
36 # should change apccontrol.sh.in and then rerun the configure process.
38 if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ]
40 ${SCRIPTDIR}/${1} ${2} ${3} ${4}
41 # exit code 99 means he does not want us to do default action
49 printf "UPS now committed to shut down" | wall
50 # echo "Apccontrol doing: ${APCUPSD} --killpower"
52 # ${APCUPSD} --killpower
55 printf "Communications with UPS lost." | wall
58 printf "Communciations with UPS restored." | wall
63 printf "Power failure. Running on UPS batteries." | wall
66 printf "Power has returned..." | wall
69 if [ -f @PWRFAILDIR@/powerfail ] ; then
70 printf "Continuing with shutdown." | wall
74 printf "UPS battery power exhaused. Doing shutdown.\n" | wall
77 printf "UPS battery runtime limit exceeded. Doing shutdown.\n" | wall
80 printf "UPS battery discharge limit reached. Doing shutdown.\n" | wall
83 printf "UPS battery runtime percent reached. Doing shutdown.\n" \
87 printf "Beginning Reboot Sequence" | wall
88 ${SHUTDOWN} -r now "apcupsd initiated reboot"
91 printf "Beginning Shutdown Sequence" | wall
92 ${SHUTDOWN} -h now "apcupsd initiated shutdown"
95 printf "Power problems please logoff." | wall
98 printf "Emergency Shutdown. Possible UPS battery failure." \
102 printf "Emergency! UPS batteries have failed\nChange them NOW" \
106 printf "Remote Shutdown.\nBeginning Shutdown Sequence." | wall
116 *) echo "Usage: ${0##*/} command"
117 echo " warning: this script is intended to be launched by"
118 echo " apcupsd and should never be launched by users."