3 AUTHOR: John McSwain <jmcswain@infoave.net>
6 Installing Apcupsd to protect an LFS system using APC UPS.
9 version 1.0 (06/27/2001)
11 ========================
13 ========================
21 3.2.3 Symlink the scripts
30 Apcupsd is useful for controlling American Power Conversion's (APC)
31 uninterruptiple power supplies (UPS). Apcupsd monitors the UPS and during a
32 power loss, informs the system users of the failure, and if power is not
33 restored, safely shuts down the system. The Apcupsd manual (available on line
34 at http://www.sibbald.com/apcupsd/manual/index.html or with the software)
35 provides excellent instructions on installing and configuring the software.
36 The configure script can identify several standard linux distributions and make
37 the correct installation. However, as LFS is by design not standard this hint
38 provides the information to protect an LFS system with an APC UPS using
41 The installation of Apcupsd is mostly straightforward until "make install" is
42 completed. Then the LFS user will see the following series of messages:
45 You have to manually install apcupsd boot script and
46 halt script for clean emergency shutdown.
47 Please contribute your distribution install to apcupsd team.
48 I'm sorry: you are on your own."
50 The purpose of this hint is to provide one method of accomplishing the above
51 actions to get Apcupsd up and running on the LFS "unknown" distribution.
57 The Apcupsd software can be found at these sites:
59 http://www.oasi.gpa.it/riccardo/linux/apcupsd/
60 http://www.sibbald.com/apcupsd/
61 ftp://ftp.oasi.gpa.it/pub/apcupsd/
63 As of this writing the latest stable release is Apcupsd-3.8.1. However
64 Apcupsd-3.8.2Beta14 has been used with no problems by this author.
71 Obtain the source and unpack it in a suitable place such as /usr/src/.
72 Compiler optimizations can be used with Apcupsd. See Optimization.txt hint
73 and the Apcupsd manual for more information.
78 Run the following command:
80 ./configure --prefix=/usr --sbindir=/sbin
82 This is a basic installation. If you have a smartups and wish to have a web
83 interface to the APC unit's status from your web server see the Apcupsd manual.
84 You will probably want to run the above commands with additions:
86 ./configure --prefix=/usr --sbindir=/sbin \
87 --with-cgi-bin=/home/httpd/cgi-bin --enable-cgi
98 At the end of the make install you will get the messages listed above in the
99 introduction. A bootscript and proper halt script must be manually
106 Use the template script in /etc/init.d as a guide to make the boot script.
111 Now edit the apcupsd file to make the following bootscript:
114 # Begin /etc/init.d/apcupsd
116 # S200 in /etc/rc{2,3,4,5}.d and K990 /etc/rc{0,1,6}.d
118 source /etc/init.d/functions
122 # House keeping if this were a restart from powerfail
123 rm -f /etc/apcupsd/powerfail
126 echo -n "Starting apcupsd power management ..."
127 loadproc /sbin/apcupsd
131 echo -n "Stopping apcupsd power management..."
136 echo -n "Reloading apcupsd power management ..."
151 echo "Usage: $0 {start|stop|reload|restart|status}"
157 # End /etc/init.d/apcupsd
160 =====================
161 3.2.2 Poweroff script
162 =====================
164 This poweroff script is needed to shutdown the UPS after the system has halted.
165 (Note: Depending on the UPS this could take a minute or two). Thus when the
166 power returns the UPS will come back on and the system will power up (providing
167 your atx bios supports powerup).
169 Apcupsd for most distributions modifies the existing halt script. Rather than
170 that route we are making a separate script called UPSdown.
172 Using a text editor create UPSdown as follows in /etc/init.d:
175 # Begin /etc/init.d/UPSdown
177 # Script to shutdown UPS after computer shutdown
179 # Symlink in rc0.d after umounting filesystems
182 # See if this is a powerfail situation
183 if [ -f /etc/apcupsd/powerfail ]; then
185 echo "APCUPSD will now power off the UPS"
187 /etc/apcupsd/apccontrol killpower
189 echo "Verify the UPS shuts down or turn off the system"
193 # End /etc/init.d/UPSdown
196 =========================
197 3.2.3 Symlink the scripts
198 =========================
199 The apcupsd daemon should be started fairly soon in the boot cycle to provide
200 protection. Using three digit symlinks, S200 for my system seems appropriate.
201 Use your own judgement here.
203 Stopping the daemon should occur fairly late. I use K990.
205 The UPSdown script should be run immediately prior to the halt script. If
206 halt is S999 then UPSdown would be S998.
211 chmod 754 apcupsd UPSdown &&
213 ln -s ../init.d/apcupsd K990apcupsd &&
214 ln -s ../init.d/UPSdown S998UPSdown &&
216 ln -s ../init.d/apcupsd K990apcupsd &&
218 ln -s ../init.d/apcupsd S200apcupsd &&
220 ln -s ../init.d/apcupsd S200apcupsd &&
222 ln -s ../init.d/apcupsd S200apcupsd &&
224 ln -s ../init.d/apcupsd S200apcupsd &&
226 ln -s ../init.d/apcupsd K990apcupsd
233 Our generic configure in 3.1 above placed the configuration file in
234 /etc/apcupsd. This file is called apcupsd.conf. Pleae consult the apcupsd
235 manual to determine the settings for your system and APC model UPS.
240 The above steps were an attempt to have you quickly provide APC UPS power
241 protection to your system using Apcupsd software. The software allows the
242 individual user a lot of options depending on his needs and desires. For
243 example I use the cgi feature to be able to see the status of my UPS from a
244 browser. I use the notification feature to mail the electric company that I
245 have loss power. These and other features along with a description of the
246 workings of Apcupsd are fully described in the Apcupsd manual.