3 AUTHOR: John McSwain <jmcswain@infoave.net>
6 Installing Apcupsd to protect an LFS system using APC UPS connected
10 version 1.1 (02/19/2003)
12 ========================
14 ========================
23 4.2.3 Symlink the scripts
32 Apcupsd is useful for controlling American Power Conversion's (APC)
33 uninterruptiple power supplies (UPS). Apcupsd monitors the UPS and during a
34 power loss, informs the system users of the failure, and if power is not
35 restored, safely shuts down the system. The Apcupsd manual (available on line
36 at http://www.sibbald.com/apcupsd/manual/index.html or with the software)
37 provides excellent instructions on installing and configuring the software.
38 The configure script can identify several standard linux distributions and make
39 the correct installation. However, as LFS is by design not standard this hint
40 provides the information to protect an LFS system with an APC UPS connected
41 via a serial connection using Apcupsd software.
43 If you are using an APC UPS that connects via USB please see the hint by
44 Bryan Mason <http://cvs.linuxfromscratch.org/index.cgi/hints/apcupsd-usb.txt>.
47 The installation of Apcupsd is mostly straightforward until "make install" is
48 completed. Then the LFS user will see the following series of messages:
51 You have to manually install apcupsd boot script and
52 halt script for clean emergency shutdown.
53 Please contribute your distribution install to apcupsd team.
54 I'm sorry: you are on your own."
56 The purpose of this hint is to provide one method of accomplishing the above
57 actions to get Apcupsd up and running on the LFS "unknown" distribution.
63 1.0 Original hint (06/27/01)
65 1.1 Updated to current script location (/etc/rc.d/init.d/), two digit symlinks,
66 software download location and latest version.
72 The Apcupsd software can currently be found at sourceforge:
74 http://download.sourceforge.net/apcupsd/
76 As of this writing the latest stable release is Apcupsd-3.8.6.
83 Obtain the source and unpack it in a suitable place such as /usr/src/.
84 Compiler optimizations can be used with Apcupsd. See Optimization.txt hint
85 and the Apcupsd manual for more information.
90 Run the following command:
92 ./configure --prefix=/usr --sbindir=/sbin
94 This is a basic installation. If you have a smartups and wish to have a web
95 interface to the APC unit's status from your web server see the Apcupsd manual.
96 You will probably want to run the above commands with additions:
98 ./configure --prefix=/usr --sbindir=/sbin \
99 --with-cgi-bin=/home/httpd/cgi-bin --enable-cgi
110 At the end of the make install you will get the messages listed above in the
111 introduction. A bootscript and proper halt script must be manually
118 Use the template script in /etc/rc.d/init.d as a guide to make the boot script.
123 Now edit the apcupsd file to make the following bootscript:
126 # Begin /etc/rc.d/init.d/apcupsd
128 # S20 in /etc/rc{2,3,4,5}.d and K95 /etc/rc{0,1,6}.d
130 source /etc/sysconfig/rc
135 # House keeping if this were a restart from powerfail
136 rm -f /etc/apcupsd/powerfail
139 echo -n "Starting apcupsd power management ..."
140 loadproc /sbin/apcupsd
144 echo -n "Stopping apcupsd power management..."
149 echo -n "Reloading apcupsd power management ..."
164 echo "Usage: $0 {start|stop|reload|restart|status}"
170 # End /etc/rc.d/init.d/apcupsd
173 =====================
174 4.2.2 Poweroff script
175 =====================
177 This poweroff script is needed to shutdown the UPS after the system has halted.
178 (Note: Depending on the UPS this could take a minute or two). Thus when the
179 power returns the UPS will come back on and the system will power up (providing
180 your atx bios supports powerup).
182 Apcupsd for most distributions modifies the existing halt script. Rather than
183 that route we are making a separate script called UPSdown.
185 Using a text editor create UPSdown as follows in /etc/rc.d/init.d:
188 # Begin /etc/rc.d/init.d/UPSdown
190 # Script to shutdown UPS after computer shutdown
192 # Symlink in rc0.d after umounting filesystems
195 # See if this is a powerfail situation
196 if [ -f /etc/apcupsd/powerfail ]; then
198 echo "APCUPSD will now power off the UPS"
200 /etc/apcupsd/apccontrol killpower
202 echo "Verify the UPS shuts down or turn off the system"
206 # End /etc/rc.d/init.d/UPSdown
209 =========================
210 4.2.3 Symlink the scripts
211 =========================
212 The apcupsd daemon should be started fairly soon in the boot cycle to provide
213 protection. Using the current two digit symlinks, S20 for my system seems
214 appropriate. Use your own judgement here.
216 Stopping the daemon should occur fairly late. I use K95.
218 The UPSdown script should be run immediately prior to the halt script. If
219 halt is K99 then UPSdown would be S98.
223 cd /etc/rc.d/init.d &&
224 chmod 755 apcupsd UPSdown &&
226 ln -s ../init.d/apcupsd K95apcupsd &&
227 ln -s ../init.d/UPSdown K98UPSdown &&
229 ln -s ../init.d/apcupsd K95apcupsd &&
231 ln -s ../init.d/apcupsd S20apcupsd &&
233 ln -s ../init.d/apcupsd S20apcupsd &&
235 ln -s ../init.d/apcupsd S20apcupsd &&
237 ln -s ../init.d/apcupsd S20apcupsd &&
239 ln -s ../init.d/apcupsd K95apcupsd
246 Our generic configure in 4.1 above placed the configuration file in
247 /etc/apcupsd. This file is called apcupsd.conf. Please consult the apcupsd
248 manual to determine the settings for your system and APC model UPS.
253 The above steps were an attempt to have you quickly provide APC UPS power
254 protection to your system using Apcupsd software. The software allows the
255 individual user a lot of options depending on his needs and desires. For
256 example I use the cgi feature to be able to see the status of my UPS from a
257 browser. I use the notification feature to mail the electric company that I
258 have loss power. These and other features along with a description of the
259 workings of Apcupsd are fully described in the Apcupsd manual.