Subversion Repositories configs

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/sh
2
#
3
# Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
4
#
16 - 5
#  for apcupsd release 3.14.12 (29 March 2014) - redhat
3 - 6
#
7
# platforms/apccontrol.  Generated from apccontrol.in by configure.
8
#
9
#  Note, this is a generic file that can be used by most
10
#   systems. If a particular system needs to have something
11
#   special, start with this file, and put a copy in the
12
#   platform subdirectory.
13
#
14
 
15
#
16
# These variables are needed for set up the autoconf other variables.
17
#
18
prefix=/usr
19
exec_prefix=/usr
20
 
21
APCPID=/var/run/apcupsd.pid
22
APCUPSD=/sbin/apcupsd
23
SHUTDOWN=/sbin/shutdown
24
SCRIPTSHELL=/bin/sh
25
SCRIPTDIR=/etc/apcupsd
26
WALL=wall
27
 
16 - 28
export SYSADMIN=root
29
export APCUPSD_MAIL="/bin/mail"
30
if [ -f $SCRIPTDIR/config ]; then . $SCRIPTDIR/config ; fi
31
 
3 - 32
#
33
# Concatenate all output from this script to the events file
34
#  Note, the following kills the script in a power fail situation
35
#   where the disks are mounted read-only.
36
# exec >>/var/log/apcupsd.events 2>&1
37
 
38
#
39
# This piece is to substitute the default behaviour with your own script,
40
# perl, or C program.
41
# You can customize every single command creating an executable file (may be a
42
# script or a compiled program) and calling it the same as the $1 parameter
43
# passed by apcupsd to this script.
44
#
45
# After executing your script, apccontrol continues with the default action.
46
# If you do not want apccontrol to continue, exit your script with exit
47
# code 99. E.g. "exit 99".
48
#
49
# WARNING: the apccontrol file will be overwritten every time you update your
50
# apcupsd, doing `make install'. Your own customized scripts will _not_ be
51
# overwritten. If you wish to make changes to this file (discouraged), you
52
# should change apccontrol.sh.in and then rerun the configure process.
53
#
54
if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ]
55
then
56
    ${SCRIPTDIR}/${1} ${2} ${3} ${4}
57
    # exit code 99 means he does not want us to do default action
58
    if [ $? = 99 ] ; then
59
	exit 0
60
    fi
61
fi
62
 
63
case "$1" in
64
    killpower)
65
	echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
66
	sleep 10
67
	${APCUPSD} --killpower
68
	echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
69
    ;;
70
    commfailure)
71
	echo "Warning communications lost with UPS ${2}" | ${WALL}
72
    ;;
73
    commok)
74
	echo "Communications restored with UPS ${2}" | ${WALL}
75
    ;;
76
#
77
# powerout, onbattery, offbattery, mainsback events occur
78
#   in that order.
79
#
80
    powerout)
81
    ;;
82
    onbattery)
83
	echo "Power failure on UPS ${2}. Running on batteries." | ${WALL}
84
    ;;
85
    offbattery)
86
	echo "Power has returned on UPS ${2}..." | ${WALL}
87
    ;;
88
    mainsback)
89
	if [ -f /etc/apcupsd/powerfail ] ; then
90
	   printf "Continuing with shutdown."  | ${WALL}
91
	fi
92
    ;;
93
    failing)
16 - 94
	echo "Battery power exhausted on UPS ${2}. Doing shutdown." | ${WALL}
3 - 95
    ;;
96
    timeout)
97
	echo "Battery time limit exceeded on UPS ${2}. Doing shutdown." | ${WALL}
98
    ;;
99
    loadlimit)
100
	echo "Remaining battery charge below limit on UPS ${2}. Doing shutdown." | ${WALL}
101
    ;;
102
    runlimit)
103
	echo "Remaining battery runtime below limit on UPS ${2}. Doing shutdown." | ${WALL}
104
    ;;
105
    doreboot)
106
	echo "UPS ${2} initiating Reboot Sequence" | ${WALL}
107
	${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot"
108
    ;;
109
    doshutdown)
110
	echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
111
	${SHUTDOWN} -h -H now "apcupsd UPS ${2} initiated shutdown"
112
    ;;
113
    annoyme)
114
	echo "Power problems with UPS ${2}. Please logoff." | ${WALL}
115
    ;;
116
    emergency)
117
	echo "Emergency Shutdown. Possible battery failure on UPS ${2}." | ${WALL}
118
    ;;
119
    changeme)
120
	echo "Emergency! Batteries have failed on UPS ${2}. Change them NOW" | ${WALL}
121
    ;;
122
    remotedown)
123
	echo "Remote Shutdown. Beginning Shutdown Sequence." | ${WALL}
124
    ;;
125
    startselftest)
126
    ;;
127
    endselftest)
128
    ;;
129
    battdetach)
130
    ;;
131
    battattach)
132
    ;;
133
    *)	echo "Usage: ${0##*/} command"
134
	echo "	     warning: this script is intended to be launched by"
135
	echo "	     apcupsd and should never be launched by users."
136
	exit 1
137
    ;;
138
esac