UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / engarde / apcupsd.spec.in
blob3b89cd9babee33bfff896c311c4d93bf2d193eeb
2 %define initdir /etc/init.d
4 Summary: APC UPS Power Control Daemon for Linux
5 Name: apcupsd
6 Version: @VERSION@
7 Release: 1
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
14 Copyright: GPL v2
15 BuildRoot: %{_tmppath}/%{name}-root
17 %description
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).
29 %prep
31 %setup
33 %build
35 %configure \
36 --prefix=%{_prefix} \
37 --sbindir=/sbin \
38 --sysconfdir=%{_sysconfdir}/apcupsd \
39 --with-cgi-bin=%{_sysconfdir}/apcupsd/cgi \
40 --enable-cgi \
41 --enable-pthreads
43 make
45 %install
47 mkdir -p $RPM_BUILD_ROOT%{initdir}
48 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/apcupsd/cgi
50 make \
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}
63 %clean
64 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
66 %files
67 %defattr(-,root,root)
68 %doc COPYING ChangeLog INSTALL TODO doc/* examples
69 %dir /etc/apcupsd
70 %dir /etc/apcupsd/cgi
71 %{initdir}/apcupsd
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
81 /etc/apcupsd/cgi/*
82 /sbin/*
83 %attr(-,root,man) %{_mandir}/*/*
85 %pre
87 %post
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\./ {
96 do {
97 getline
98 } while (length($0) != 0)
99 getline
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***"
114 print ""
116 # Everything else is duplicated
117 { print } ' /etc/init.d/halt.old > /etc/init.d/halt
119 chmod 744 /etc/init.d/halt
121 # Undo things a bit
123 %preun
124 if [ $1 = 0 ] ; then
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\./ {
139 do {
140 getline
141 } while (length($0) != 0)
142 getline
144 # Everything else is duplicated
145 { print } ' /etc/init.d/halt.old > /etc/init.d/halt
147 chmod 744 /etc/init.d/halt
150 %postun
151 if [ "$1" -ge "1" ]; then
153 # /sbin/service apcupsd condrestart >/dev/null 2>&1 || :
156 %changelog
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.