UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / openbsd / apccontrol.in
blob43b0213ec8ba0cab3a3c14afe6121d68352246bc
1 #!@SCRIPTSHELL@
3 # Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
5 #  for apcupsd release @VERSION@ (@DATE@) - @DISTNAME@
7 # @configure_input@
11 # These variables are needed for set up the autoconf other variables.
13 prefix=@prefix@
14 exec_prefix=@exec_prefix@
16 APCPID=@PIDDIR@/apcupsd.pid
17 APCUPSD=@sbindir@/apcupsd
18 SHUTDOWN=@SHUTDOWN@
19 SCRIPTSHELL=@SCRIPTSHELL@
20 SCRIPTDIR=@sysconfdir@
23 # This piece is to substitute the default behaviour with your own script,
24 # perl, or C program.
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} ]
39 then
40         ${SCRIPTDIR}/${1} ${2} ${3} ${4}
41         # exit code 99 means he does not want us to do default action
42         if [ $? = 99 ] ; then
43                 exit 0
44         fi
47 case "$1" in
48         killpower)
49                 printf "UPS now committed to shut down" | wall
50 #                echo "Apccontrol doing: ${APCUPSD} --killpower"       
51 #                sleep 10
52 #                ${APCUPSD} --killpower
53         ;;
54         commfailure)
55                 printf "Communications with UPS lost." | wall
56         ;;
57         commok)
58                 printf "Communciations with UPS restored." | wall
59         ;;
60         powerout)
61         ;;
62         onbattery)
63                 printf "Power failure. Running on UPS batteries." | wall
64         ;;
65         offbattery)
66                 printf "Power has returned..." | wall
67         ;;
68         mainsback)
69                 if [ -f @PWRFAILDIR@/powerfail ] ; then
70                    printf "Continuing with shutdown."  | wall
71                 fi
72         ;;
73         failing)
74                 printf "UPS battery power exhaused. Doing shutdown.\n" | wall
75         ;;
76         timeout)
77                 printf "UPS battery runtime limit exceeded. Doing shutdown.\n" | wall
78         ;;
79         loadlimit)
80                 printf "UPS battery discharge limit reached. Doing shutdown.\n" | wall
81         ;;
82         runlimit)
83                 printf "UPS battery runtime percent reached. Doing shutdown.\n" \
84                         | wall
85         ;;
86         doreboot)
87                 printf "Beginning Reboot Sequence" | wall
88                 ${SHUTDOWN} -r now "apcupsd initiated reboot"
89         ;;
90         doshutdown)
91                 printf "Beginning Shutdown Sequence" | wall
92                 ${SHUTDOWN} -h now "apcupsd initiated shutdown"
93         ;;
94         annoyme)
95                 printf "Power problems please logoff." | wall
96         ;;
97         emergency)
98                 printf "Emergency Shutdown. Possible UPS battery failure." \
99                         | wall
100         ;;
101         changeme)
102                 printf "Emergency! UPS batteries have failed\nChange them NOW" \
103                         | wall
104         ;;
105         remotedown)
106                 printf "Remote Shutdown.\nBeginning Shutdown Sequence." | wall
107         ;;
108         startselftest)
109         ;;
110         endselftest)
111         ;;
112         battdetach)
113         ;;
114         battattach)
115         ;;
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."
119                 exit 1
120         ;;
121 esac