瀏覽代碼

apcupsd: move from old packages and Makefile updated

Signed-off-by: Othmar Truniger <Othmar Truniger github@truniger.ch>
Othmar Truniger 10 年之前
父節點
當前提交
a460965a67

+ 78
- 0
net/apcupsd/Makefile 查看文件

@@ -0,0 +1,78 @@
1
+#
2
+# Copyright (C) 2006-2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=apcupsd
11
+PKG_VERSION:=3.14.13
12
+PKG_RELEASE:=2
13
+
14
+PKG_MAINTAINER:=Othmar Truniger <github@truniger.ch>
15
+PKG_LICENSE:=GPL-2.0
16
+PKG_LICENSE_FILES:=COPYING
17
+
18
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
19
+PKG_SOURCE_URL:=@SF/apcupsd
20
+PKG_MD5SUM:=c291d9d3923b4d9c0e600b755ad4f489
21
+
22
+include $(INCLUDE_DIR)/package.mk
23
+
24
+define Package/apcupsd
25
+  SECTION:=utils
26
+  CATEGORY:=Utilities
27
+  DEPENDS:=+libpthread +libusb-compat
28
+  TITLE:=UPS control software
29
+  URL:=http://www.apcupsd.org/
30
+endef
31
+
32
+define Build/Configure
33
+	$(CP) $(SCRIPT_DIR)/config.* $(PKG_BUILD_DIR)/autoconf/
34
+	$(call Build/Configure/Default, \
35
+		--with-distname=unknown \
36
+		--sysconfdir=/etc/apcupsd \
37
+		--enable-usb \
38
+		--without-x \
39
+	)
40
+endef
41
+
42
+define Build/Compile
43
+	$(MAKE) -C $(PKG_BUILD_DIR) \
44
+		DESTDIR="$(PKG_INSTALL_DIR)" \
45
+		LD="$(TARGET_CC)" \
46
+		all install
47
+endef
48
+
49
+define Package/apcupsd/install
50
+	$(INSTALL_DIR) $(1)/usr/sbin
51
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/apcupsd $(1)/usr/sbin/
52
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smtp $(1)/usr/sbin/
53
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/apctest $(1)/usr/sbin/
54
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/apcaccess $(1)/usr/sbin/
55
+	$(INSTALL_DIR) $(1)/etc/apcupsd
56
+	$(INSTALL_CONF) ./files/apcupsd.conf $(1)/etc/apcupsd/
57
+	$(INSTALL_CONF) ./files/apcupsd_mail.conf $(1)/etc/apcupsd/
58
+	$(INSTALL_BIN) ./files/changeme $(1)/etc/apcupsd/
59
+	$(INSTALL_BIN) ./files/commfailure $(1)/etc/apcupsd/
60
+	$(INSTALL_BIN) ./files/commok $(1)/etc/apcupsd/
61
+	$(INSTALL_BIN) ./files/offbattery $(1)/etc/apcupsd/
62
+	$(INSTALL_BIN) ./files/onbattery $(1)/etc/apcupsd/
63
+	$(INSTALL_BIN) ./files/apccontrol $(1)/etc/apcupsd/
64
+	$(INSTALL_DIR) $(1)/etc/init.d
65
+	$(INSTALL_BIN)	./files/apcupsd.init $(1)/etc/init.d/apcupsd
66
+endef
67
+
68
+define Package/apcupsd/conffiles
69
+/etc/apcupsd/apcupsd.conf
70
+/etc/apcupsd/apcupsd_mail.conf
71
+/etc/apcupsd/changeme
72
+/etc/apcupsd/commfailure
73
+/etc/apcupsd/commok
74
+/etc/apcupsd/offbattery
75
+/etc/apcupsd/onbattery
76
+endef
77
+
78
+$(eval $(call BuildPackage,apcupsd))

+ 146
- 0
net/apcupsd/files/apccontrol 查看文件

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

+ 322
- 0
net/apcupsd/files/apcupsd.conf 查看文件

@@ -0,0 +1,322 @@
1
+## apcupsd.conf v1.1 ##
2
+# 
3
+#  for apcupsd release 3.14.1 (04 May 2007) - unknown
4
+#
5
+# "apcupsd" POSIX config file
6
+
7
+#
8
+# ========= General configuration parameters ============
9
+#
10
+
11
+# UPSNAME xxx
12
+#   Use this to give your UPS a name in log files and such. This
13
+#   is particulary useful if you have multiple UPSes. This does not
14
+#   set the EEPROM. It should be 8 characters or less.
15
+UPSNAME ups1
16
+
17
+# UPSCABLE <cable>
18
+#   Defines the type of cable connecting the UPS to your computer.
19
+#
20
+#   Possible generic choices for <cable> are:
21
+#     simple, smart, ether, usb
22
+#
23
+#   Or a specific cable model number may be used:
24
+#     940-0119A, 940-0127A, 940-0128A, 940-0020B,
25
+#     940-0020C, 940-0023A, 940-0024B, 940-0024C,
26
+#     940-1524C, 940-0024G, 940-0095A, 940-0095B,
27
+#     940-0095C, M-04-02-2000
28
+#
29
+UPSCABLE smart
30
+
31
+# To get apcupsd to work, in addition to defining the cable
32
+# above, you must also define a UPSTYPE, which corresponds to
33
+# the type of UPS you have (see the Description for more details).
34
+# You must also specify a DEVICE, sometimes referred to as a port.
35
+# For USB UPSes, please leave the DEVICE directive blank. For
36
+# other UPS types, you must specify an appropriate port or address.
37
+#
38
+# UPSTYPE   DEVICE           Description
39
+# apcsmart  /dev/tty**       Newer serial character device,
40
+#                            appropriate for SmartUPS models using
41
+#                            a serial cable (not USB).
42
+#
43
+# usb       <BLANK>          Most new UPSes are USB. A blank DEVICE
44
+#                            setting enables autodetection, which is
45
+#                            the best choice for most installations.
46
+#
47
+# net       hostname:port    Network link to a master apcupsd
48
+#                            through apcupsd's Network Information
49
+#                            Server. This is used if you don't have
50
+#                            a UPS directly connected to your computer.
51
+#
52
+# snmp      hostname:port:vendor:community
53
+#                            SNMP Network link to an SNMP-enabled
54
+#                            UPS device. Vendor is the MIB used by
55
+#                            the UPS device: can be "APC", "APC_NOTRAP"
56
+#                            or "RFC" where APC is the powernet MIB,
57
+#                            "APC_NOTRAP" is powernet with SNMP trap
58
+#                            catching disabled, and RFC is the IETF's 
59
+#                            rfc1628 UPS-MIB. You usually want "APC".
60
+#                            Port is usually 161. Community is usually
61
+#                            "private".
62
+#
63
+# dumb      /dev/tty**       Old serial character device for use 
64
+#                            with simple-signaling UPSes.
65
+#
66
+# pcnet    ipaddr:username:passphrase
67
+#                            PowerChute Network Shutdown protocol
68
+#                            which can be used as an alternative to SNMP
69
+#                            with AP9617 family of smart slot cards.
70
+#                            ipaddr is the IP address of the UPS mgmt
71
+#                            card. username and passphrase are the
72
+#                            credentials for which the card has been
73
+#                            configured.
74
+#
75
+UPSTYPE apcsmart
76
+DEVICE /dev/ttyS0
77
+
78
+
79
+# LOCKFILE <path to lockfile>
80
+#   Path for device lock file. Not used on Win32.
81
+LOCKFILE /var/lock
82
+
83
+# SCRIPTDIR <path to script directory>
84
+#   Directory in which apccontrol and event scripts are located.
85
+SCRIPTDIR /etc/apcupsd
86
+
87
+# PWRFAILDIR <path to powerfail directory>
88
+#   Directory in which to write the powerfail flag file. This file
89
+#   is created when apcupsd initiates a system shutdown and is
90
+#   checked in the OS halt scripts to determine if a killpower
91
+#   (turning off UPS output power) is required.
92
+PWRFAILDIR /etc
93
+
94
+# NOLOGINDIR <path to nologin directory>
95
+#   Directory in which to write the nologin file. The existence
96
+#   of this flag file tells the OS to disallow new logins.
97
+NOLOGINDIR /etc
98
+
99
+
100
+#
101
+# ======== Configuration parameters used during power failures ==========
102
+#
103
+
104
+# The ONBATTERYDELAY is the time in seconds from when a power failure
105
+#   is detected until we react to it with an onbattery event.
106
+#
107
+#   This means that, apccontrol will be called with the powerout argument
108
+#   immediately when a power failure is detected.  However, the
109
+#   onbattery argument is passed to apccontrol only after the 
110
+#   ONBATTERYDELAY time.  If you don't want to be annoyed by short
111
+#   powerfailures, make sure that apccontrol powerout does nothing
112
+#   i.e. comment out the wall.
113
+#ONBATTERYDELAY 6
114
+
115
+# 
116
+# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
117
+# the first that occurs will cause the initation of a shutdown.
118
+#
119
+
120
+# If during a power failure, the remaining battery percentage
121
+# (as reported by the UPS) is below or equal to BATTERYLEVEL, 
122
+# apcupsd will initiate a system shutdown.
123
+BATTERYLEVEL 5
124
+
125
+# If during a power failure, the remaining runtime in minutes 
126
+# (as calculated internally by the UPS) is below or equal to MINUTES,
127
+# apcupsd, will initiate a system shutdown.
128
+MINUTES 3
129
+
130
+# If during a power failure, the UPS has run on batteries for TIMEOUT
131
+# many seconds or longer, apcupsd will initiate a system shutdown.
132
+# A value of 0 disables this timer.
133
+#
134
+#  Note, if you have a Smart UPS, you will most likely want to disable
135
+#    this timer by setting it to zero. That way, you UPS will continue
136
+#    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
137
+#    or the remaining battery runtime drops to or below MINUTES.  Of course,
138
+#    if you are testing, setting this to 60 causes a quick system shutdown
139
+#    if you pull the power plug.   
140
+#  If you have an older dumb UPS, you will want to set this to less than
141
+#    the time you know you can run on batteries.
142
+TIMEOUT 0
143
+
144
+#  Time in seconds between annoying users to signoff prior to
145
+#  system shutdown. 0 disables.
146
+ANNOY 300
147
+
148
+# Initial delay after power failure before warning users to get
149
+# off the system.
150
+ANNOYDELAY 60
151
+
152
+# The condition which determines when users are prevented from
153
+# logging in during a power failure.
154
+# NOLOGON <string> [ disable | timeout | percent | minutes | always ]
155
+NOLOGON disable
156
+
157
+# If KILLDELAY is non-zero, apcupsd will continue running after a
158
+# shutdown has been requested, and after the specified time in
159
+# seconds attempt to kill the power. This is for use on systems
160
+# where apcupsd cannot regain control after a shutdown.
161
+# KILLDELAY <seconds>  0 disables
162
+KILLDELAY 0
163
+
164
+#
165
+# ==== Configuration statements for Network Information Server ====
166
+#
167
+
168
+# NETSERVER [ on | off ] on enables, off disables the network
169
+#  information server. If netstatus is on, a network information
170
+#  server process will be started for serving the STATUS and
171
+#  EVENT data over the network (used by CGI programs).
172
+NETSERVER on
173
+
174
+# NISIP <dotted notation ip address>
175
+#  IP address on which NIS server will listen for incoming connections.
176
+#  This is useful if your server is multi-homed (has more than one
177
+#  network interface and IP address). Default value is 0.0.0.0 which
178
+#  means any incoming request will be serviced. Alternatively, you can
179
+#  configure this setting to any specific IP address of your server and 
180
+#  NIS will listen for connections only on that interface. Use the
181
+#  loopback address (127.0.0.1) to accept connections only from the
182
+#  local machine.
183
+NISIP 0.0.0.0
184
+
185
+# NISPORT <port> default is 3551 as registered with the IANA
186
+#  port to use for sending STATUS and EVENTS data over the network.
187
+#  It is not used unless NETSERVER is on. If you change this port,
188
+#  you will need to change the corresponding value in the cgi directory
189
+#  and rebuild the cgi programs.
190
+NISPORT 3551
191
+
192
+# If you want the last few EVENTS to be available over the network
193
+# by the network information server, you must define an EVENTSFILE.
194
+EVENTSFILE /var/log/apcupsd.events
195
+
196
+# EVENTSFILEMAX <kilobytes>
197
+#  By default, the size of the EVENTSFILE will be not be allowed to exceed
198
+#  10 kilobytes.  When the file grows beyond this limit, older EVENTS will
199
+#  be removed from the beginning of the file (first in first out).  The
200
+#  parameter EVENTSFILEMAX can be set to a different kilobyte value, or set
201
+#  to zero to allow the EVENTSFILE to grow without limit.
202
+EVENTSFILEMAX 10
203
+
204
+#
205
+# ========== Configuration statements used if sharing =============
206
+#            a UPS with more than one machine
207
+
208
+# NETTIME <int>
209
+#   Interval (in seconds) at which the NIS client polls the server.
210
+#   Used only when this apcupsd is a network client (UPSTYPE net).
211
+#NETTIME 60
212
+
213
+#
214
+# Remaining items are for ShareUPS (APC expansion card) ONLY
215
+#
216
+
217
+# UPSCLASS [ standalone | shareslave | sharemaster ]
218
+#   Normally standalone unless you share an UPS using an APC ShareUPS
219
+#   card.
220
+UPSCLASS standalone
221
+
222
+# UPSMODE [ disable | share ]
223
+#   Normally disable unless you share an UPS using an APC ShareUPS card.
224
+UPSMODE disable
225
+
226
+#
227
+# ===== Configuration statements to control apcupsd system logging ========
228
+#
229
+
230
+# Time interval in seconds between writing the STATUS file; 0 disables
231
+STATTIME 0
232
+
233
+# Location of STATUS file (written to only if STATTIME is non-zero)
234
+STATFILE /var/log/apcupsd.status
235
+
236
+# LOGSTATS [ on | off ] on enables, off disables
237
+# Note! This generates a lot of output, so if         
238
+#       you turn this on, be sure that the
239
+#       file defined in syslog.conf for LOG_NOTICE is a named pipe.
240
+#  You probably do not want this on.
241
+LOGSTATS off
242
+
243
+# Time interval in seconds between writing the DATA records to
244
+#   the log file. 0 disables.
245
+DATATIME 0
246
+
247
+# FACILITY defines the logging facility (class) for logging to syslog. 
248
+#          If not specified, it defaults to "daemon". This is useful 
249
+#          if you want to separate the data logged by apcupsd from other
250
+#          programs.
251
+#FACILITY DAEMON
252
+
253
+#
254
+# ========== Configuration statements used in updating the UPS EPROM =========
255
+#
256
+
257
+#
258
+# These statements are used only by apctest when choosing "Set EEPROM with conf
259
+# file values" from the EEPROM menu. THESE STATEMENTS HAVE NO EFFECT ON APCUPSD.
260
+#
261
+
262
+# UPS name, max 8 characters 
263
+#UPSNAME UPS_IDEN
264
+
265
+# Battery date - 8 characters
266
+#BATTDATE mm/dd/yy
267
+
268
+# Sensitivity to line voltage quality (H cause faster transfer to batteries)  
269
+# SENSITIVITY H M L        (default = H)
270
+#SENSITIVITY H
271
+
272
+# UPS delay after power return (seconds)
273
+# WAKEUP 000 060 180 300   (default = 0)
274
+#WAKEUP 60
275
+
276
+# UPS Grace period after request to power off (seconds)
277
+# SLEEP 020 180 300 600    (default = 20)
278
+#SLEEP 180
279
+
280
+# Low line voltage causing transfer to batteries
281
+# The permitted values depend on your model as defined by last letter 
282
+#  of FIRMWARE or APCMODEL. Some representative values are:
283
+#    D 106 103 100 097
284
+#    M 177 172 168 182
285
+#    A 092 090 088 086
286
+#    I 208 204 200 196     (default = 0 => not valid)
287
+#LOTRANSFER  208
288
+
289
+# High line voltage causing transfer to batteries
290
+# The permitted values depend on your model as defined by last letter 
291
+#  of FIRMWARE or APCMODEL. Some representative values are:
292
+#    D 127 130 133 136
293
+#    M 229 234 239 224
294
+#    A 108 110 112 114
295
+#    I 253 257 261 265     (default = 0 => not valid)
296
+#HITRANSFER 253
297
+
298
+# Battery charge needed to restore power
299
+# RETURNCHARGE 00 15 50 90 (default = 15)
300
+#RETURNCHARGE 15
301
+
302
+# Alarm delay 
303
+# 0 = zero delay after pwr fail, T = power fail + 30 sec, L = low battery, N = never
304
+# BEEPSTATE 0 T L N        (default = 0)
305
+#BEEPSTATE T
306
+
307
+# Low battery warning delay in minutes
308
+# LOWBATT 02 05 07 10      (default = 02)
309
+#LOWBATT 2
310
+
311
+# UPS Output voltage when running on batteries
312
+# The permitted values depend on your model as defined by last letter 
313
+#  of FIRMWARE or APCMODEL. Some representative values are:
314
+#    D 115
315
+#    M 208
316
+#    A 100
317
+#    I 230 240 220 225     (default = 0 => not valid)
318
+#OUTPUTVOLTS 230
319
+
320
+# Self test interval in hours 336=2 weeks, 168=1 week, ON=at power on
321
+# SELFTEST 336 168 ON OFF  (default = 336)
322
+#SELFTEST 336

+ 12
- 0
net/apcupsd/files/apcupsd.init 查看文件

@@ -0,0 +1,12 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2006 OpenWrt.org
3
+START=50
4
+STOP=50
5
+
6
+start() {
7
+	/usr/sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
8
+}
9
+
10
+stop() {
11
+	kill $(cat /var/run/apcupsd.pid)
12
+}

+ 7
- 0
net/apcupsd/files/apcupsd_mail.conf 查看文件

@@ -0,0 +1,7 @@
1
+#!/bin/sh
2
+
3
+MAILPROG="/usr/sbin/smtp"
4
+MAILHOST="mail:25"
5
+FROM="OpenWrt"
6
+TO="apcups@example.com"
7
+HOSTNAME="OpenWrt"

+ 17
- 0
net/apcupsd/files/changeme 查看文件

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# This shell script if placed in /etc/apcupsd
4
+# will be called by /etc/apcupsd/apccontrol when apcupsd
5
+# detects that the battery should be replaced.
6
+# We send an email message to root to notify him.
7
+#
8
+. /etc/apcupsd/apcupsd_mail.conf
9
+
10
+MSG="$HOSTNAME UPS battery needs changing NOW."
11
+#
12
+(
13
+   echo "$MSG"
14
+   echo " "
15
+   /usr/sbin/apcaccess status
16
+) | $MAILPROG -h $MAILHOST -f $FROM -s "$MSG" $TO
17
+exit 0

+ 17
- 0
net/apcupsd/files/commfailure 查看文件

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# This shell script if placed in /etc/apcupsd
4
+# will be called by /etc/apcupsd/apccontrol when apcupsd
5
+# loses contact with the UPS (i.e. the serial connection is not responding).
6
+# We send an email message to root to notify him.
7
+#
8
+. /etc/apcupsd/apcupsd_mail.conf
9
+
10
+MSG="$HOSTNAME Communications with UPS lost"
11
+#
12
+(
13
+   echo "$MSG"
14
+   echo " "
15
+   /usr/sbin/apcaccess status
16
+) | $MAILPROG -h $MAILHOST -f $FROM -s "$MSG" $TO
17
+exit 0

+ 17
- 0
net/apcupsd/files/commok 查看文件

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# This shell script if placed in /etc/apcupsd
4
+# will be called by /etc/apcupsd/apccontrol when apcupsd
5
+# restores contact with the UPS (i.e. the serial connection is restored).
6
+# We send an email message to root to notify him.
7
+#
8
+. /etc/apcupsd/apcupsd_mail.conf
9
+
10
+MSG="$HOSTNAME Communications with UPS restored"
11
+#
12
+(
13
+   echo "$MSG"
14
+   echo " "
15
+   /usr/sbin/apcaccess status
16
+) | $MAILPROG -h $MAILHOST -f $FROM -s "$MSG" $TO
17
+exit 0

+ 17
- 0
net/apcupsd/files/offbattery 查看文件

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# This shell script if placed in /etc/apcupsd
4
+# will be called by /etc/apcupsd/apccontrol when apcupsd
5
+# restores contact with the UPS (i.e. the serial connection is restored).
6
+# We send an email message to root to notify him.
7
+#
8
+. /etc/apcupsd/apcupsd_mail.conf
9
+
10
+MSG="$HOSTNAME Communications with UPS restored"
11
+#
12
+(
13
+   echo "$MSG"
14
+   echo " "
15
+   /usr/sbin/apcaccess status
16
+) | $MAILPROG -h $MAILHOST -f $FROM -s "$MSG" $TO
17
+exit 0

+ 17
- 0
net/apcupsd/files/onbattery 查看文件

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+#
3
+# This shell script if placed in /etc/apcupsd
4
+# will be called by /etc/apcupsd/apccontrol when the UPS
5
+# goes on batteries.
6
+# We send an email message to root to notify him.
7
+#
8
+. /etc/apcupsd/apcupsd_mail.conf
9
+
10
+MSG="$HOSTNAME Power Failure !!!"
11
+#
12
+(
13
+   echo "$MSG"
14
+   echo " "
15
+   /usr/sbin/apcaccess status
16
+) | $MAILPROG -h $MAILHOST -f $FROM -s "$MSG" $TO
17
+exit 0

+ 13
- 0
net/apcupsd/patches/010-fix-include-paths.patch 查看文件

@@ -0,0 +1,13 @@
1
+diff --git a/autoconf/variables.mak.in b/autoconf/variables.mak.in
2
+index b67e467..6022434 100644
3
+--- a/autoconf/variables.mak.in
4
++++ b/autoconf/variables.mak.in
5
+@@ -65,7 +65,7 @@ DRVLIBS = @PTHREAD_LFLAGS@ @DRVLIBS@
6
+ X_LIBS = @X_LIBS@
7
+ X_EXTRA_LIBS = @X_EXTRA_LIBS@
8
+ 
9
+-CPPFLAGS = @CPPFLAGS@ -I$(topdir)/include $(EXTRAINCS)
10
++CPPFLAGS = -I$(topdir)/include @CPPFLAGS@ $(EXTRAINCS)
11
+ CFLAGS = $(CPPFLAGS) @CFLAGS@ @PTHREAD_CFLAGS@
12
+ CXXFLAGS = $(CPPFLAGS) @CXXFLAGS@ @PTHREAD_CFLAGS@
13
+ LDFLAGS = @LDFLAGS@