2 %define initdir
/etc
/init.d
4 Summary: APC UPS Power Control Daemon
for Linux
8 Vendor: APC UPS Daemon Team
9 Distribution: The apcupsd Team
10 Packager: Kern Sibbald
<kern@sibbald.com
>
11 URL: http
://www.sibbald.com
/apcupsd
/
12 Source: http
://www.sibbald.com
/apcupsd
/%{name}-%{version}.tar.gz
13 Group: System Environment
/Daemons
15 BuildRoot: %{_tmppath}/%{name}-root
18 Apcupsd can be used
for controlling most APC UPSes. During a
19 power failure
, apcupsd will inform the users about the power
20 failure and that a shutdown may occur. If power is not restored
,
21 a system shutdown will follow when the battery is exausted
, a
22 timeout
(seconds
) expires
, or the battery runtime expires based
23 on internal APC calculations determined by power consumption
24 rates. If the power is restored before one of the above shutdown
25 conditions is met
, apcupsd will inform users about this fact.
26 Some features depend on what UPS model you have
(simple or smart
).
38 --sysconfdir
=%{_sysconfdir}/apcupsd \
39 --with
-cgi
-bin
=%{_sysconfdir}/apcupsd
/cgi \
47 mkdir -p $RPM_BUILD_ROOT
%{initdir}
48 mkdir -p $RPM_BUILD_ROOT
%{_sysconfdir}/apcupsd
/cgi
51 prefix
=$RPM_BUILD_ROOT
%{_prefix} \
52 sbindir
=$RPM_BUILD_ROOT
/sbin \
53 sysconfdir
=$RPM_BUILD_ROOT
%{_sysconfdir}/apcupsd \
54 cgibin
=$RPM_BUILD_ROOT
%{_sysconfdir}/apcupsd
/cgi \
55 mandir
=$RPM_BUILD_ROOT
%{_mandir} \
56 install-apcupsd
install-cgi
58 install -m744 distributions
/redhat
/apccontrol.sh \
59 $RPM_BUILD_ROOT
%{_sysconfdir}/apcupsd
/apccontrol
60 install -m755 distributions
/redhat
/apcupsd $RPM_BUILD_ROOT
%{initdir}
64 [ "$RPM_BUILD_ROOT"
!= "
/"
] && rm -rf $RPM_BUILD_ROOT
68 %doc COPYING ChangeLog INSTALL TODO doc
/* examples
72 %config(noreplace
) /etc
/apcupsd
/apccontrol
73 %config(noreplace
) /etc
/apcupsd
/changeme
74 %config(noreplace
) /etc
/apcupsd
/commfailure
75 %config(noreplace
) /etc
/apcupsd
/commok
76 %config(noreplace
) /etc
/apcupsd
/onbattery
77 %config(noreplace
) /etc
/apcupsd
/offbattery
78 %config(noreplace
) /etc
/apcupsd
/apcupsd.conf
79 %config(noreplace
) /etc
/apcupsd
/hosts.conf
80 %config(noreplace
) /etc
/apcupsd
/multimon.conf
83 %attr(-,root
,man
) %{_mandir}/*/*
89 # delete then add our links
90 /sbin
/chkconfig
--del apcupsd
91 /sbin
/chkconfig
--add apcupsd
93 cp
-f
/etc
/init.d
/halt
/etc
/init.d
/halt.old
94 awk '
# Stuff left over from a previous apcupsd, remove it
95 /^
# See if this is a powerfail situation\./ {
98 } while (length
($
0) != 0)
101 # We insert the new apcupsd code just before the following line
102 /^
# Now halt or reboot\./ {
103 print "
# See if this is a powerfail situation. # ***apcupsd***"
104 print "
if [ -f @PWRFAILDIR@
/powerfail
]; then # ***apcupsd***"
105 print "
echo # ***apcupsd***"
106 print "
echo \"APCUPSD will now power off the UPS\"
# ***apcupsd***"
107 print "
echo # ***apcupsd***"
108 print "
/etc
/apcupsd
/apccontrol killpower
# ***apcupsd***"
109 print "
echo # ***apcupsd***"
110 print "
echo \"Please ensure that the UPS has powered off before rebooting\"
# ***apcupsd***"
111 print "
echo \"Otherwise
, the UPS may cut the power during the reboot
!!!\"
# ***apcupsd***"
112 print "
echo # ***apcupsd***"
113 print "
fi # ***apcupsd***"
116 # Everything else is duplicated
117 { print
} '
/etc
/init.d
/halt.old
> /etc
/init.d
/halt
119 chmod
744 /etc
/init.d
/halt
125 # stop running version (if any)
126 # I have removed the following because it sometimes produces
127 # an error message which may confuse someone.
128 #/sbin/service apcupsd stop
130 # remove startup links
131 /sbin
/chkconfig
--del apcupsd
133 # restore old halt script (hopefully)
134 # mv -f /etc/init.d/halt.old /etc/init.d/halt
136 cp
-f
/etc
/init.d
/halt
/etc
/init.d
/halt.old
137 awk '
# Stuff added by apcupsd, remove it
138 /^
# See if this is a powerfail situation\./ {
141 } while (length
($
0) != 0)
144 # Everything else is duplicated
145 { print
} '
/etc
/init.d
/halt.old
> /etc
/init.d
/halt
147 chmod
744 /etc
/init.d
/halt
151 if [ "$
1"
-ge "
1"
]; then
153 # /sbin/service apcupsd condrestart >/dev/null 2>&1 || :
157 * Wed Sep
05 2001 kern@sibbald.com
158 - Applied very nice patch to this spec by Giulio Orsero
<giulioo@pobox.com
>
159 * Thu Sep
14 2000 kern@sibbald.com
160 - Many thanks to Fredrik Persson and Neil Darlow
for helping me write this spec file.