UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / unknown / lfs-install-hint.txt
blob4430364ef24ff69763383c4e2e0c19ad7cf62cc0
1 TITLE:          Apcupsd\r
2 LFS VERSION:    any \r
3 AUTHOR:         John McSwain <jmcswain@infoave.net>\r
4 \r
5 SYNOPSIS:\r
6         Installing Apcupsd to protect an LFS system using APC UPS.    \r
7 \r
8 HINT:\r
9 version 1.0 (06/27/2001)\r
11 ========================\r
12 TABLE OF CONTENTS\r
13 ========================\r
14 1 Introduction\r
15 2 Software\r
16 3 Installation\r
17   3.1 Generic\r
18   3.2 LFS specific\r
19       3.2.1 Boot script\r
20       3.2.2 Poweroff script\r
21       3.2.3 Symlink the scripts\r
22 4 Configuration      \r
23 5 Conclusion\r
26 =================\r
27 1. Introduction\r
28 =================\r
30 Apcupsd is useful for controlling American Power Conversion's (APC)\r
31 uninterruptiple power supplies (UPS).  Apcupsd monitors the UPS and during a\r
32 power loss, informs the system users of the failure, and if power is not \r
33 restored, safely shuts down the system.  The Apcupsd manual (available on line\r
34 at http://www.sibbald.com/apcupsd/manual/index.html or with the software)\r
35 provides excellent instructions on installing and configuring the software.\r
36 The configure script can identify several standard linux distributions and make\r
37 the correct installation. However, as LFS is by design not standard this hint\r
38 provides the information to protect an LFS system with an APC UPS using\r
39 Apcupsd.\r
41 The installation of Apcupsd is mostly straightforward until "make install" is\r
42 completed. Then the LFS user will see the following series of messages:\r
44 "Unknown distribution\r
45 You have to manually install apcupsd boot script and\r
46 halt script for clean emergency shutdown.\r
47 Please contribute your distribution install to apcupsd team.\r
48 I'm sorry: you are on your own."\r
50 The purpose of this hint is to provide one method of accomplishing the above\r
51 actions to get Apcupsd up and running on the LFS "unknown" distribution.\r
53 =================\r
54 2. Software\r
55 =================\r
57 The Apcupsd software can be found at these sites:\r
59 http://www.oasi.gpa.it/riccardo/linux/apcupsd/\r
60 http://www.sibbald.com/apcupsd/\r
61 ftp://ftp.oasi.gpa.it/pub/apcupsd/\r
63 As of this writing the latest stable release is Apcupsd-3.8.1.  However \r
64 Apcupsd-3.8.2Beta14 has been used with no problems by this author.\r
67 ===================\r
68 3. Installation\r
69 ===================\r
71 Obtain the source and unpack it in a suitable place such as /usr/src/.\r
72 Compiler optimizations can be used with Apcupsd.  See Optimization.txt hint\r
73 and the Apcupsd manual for more information.\r
75 ===================\r
76 3.1 Generic\r
77 ===================\r
78 Run the following command:\r
80 ./configure --prefix=/usr --sbindir=/sbin\r
82 This is a basic installation.  If you have a smartups and wish to have a web\r
83 interface to the APC unit's status from your web server see the Apcupsd manual.\r
84 You will probably want to run the above commands with additions:\r
86 ./configure --prefix=/usr --sbindir=/sbin \\r
87  --with-cgi-bin=/home/httpd/cgi-bin --enable-cgi\r
89 Now run:\r
91 make &&\r
92 make install\r
94 ===================\r
95 3.2 LFS specific\r
96 ===================\r
98 At the end of the make install you will get the messages listed above in the\r
99 introduction.  A bootscript and proper halt script must be manually\r
100 installed.\r
102 ==================\r
103 3.2.1 Bootscript\r
104 ==================\r
106 Use the template script in /etc/init.d as a guide to make the boot script.\r
108 cd /etc/init.d\r
109 cp template apcupsd\r
111 Now edit the apcupsd file to make the following bootscript:\r
113 #!/bin/sh\r
114 # Begin /etc/init.d/apcupsd\r
116 # S200 in /etc/rc{2,3,4,5}.d and K990 /etc/rc{0,1,6}.d\r
118 source /etc/init.d/functions\r
120 case "$1" in\r
121         start)\r
122                 # House keeping if this were a restart from powerfail\r
123                 rm -f /etc/apcupsd/powerfail\r
124                 rm -f /etc/nologin\r
125                 # Start apcupsd\r
126                 echo -n "Starting apcupsd power management ..."\r
127                 loadproc /sbin/apcupsd\r
128                 ;;\r
130         stop)\r
131                 echo -n "Stopping apcupsd power management..."\r
132                 killproc apcupsd\r
133                 ;;\r
135         reload)\r
136                 echo -n "Reloading apcupsd power management ..."\r
137                 reloadproc apcupsd\r
138                 ;;\r
140         restart)\r
141                 $0 stop\r
142                 sleep 1\r
143                 $0 start\r
144                 ;;\r
146         status)\r
147                 statusproc apcupsd\r
148                 ;;\r
150         *)\r
151                 echo "Usage: $0 {start|stop|reload|restart|status}"\r
152                 exit 1\r
153         ;;\r
155 esac\r
157 # End /etc/init.d/apcupsd\r
160 =====================\r
161 3.2.2 Poweroff script\r
162 =====================\r
164 This poweroff script is needed to shutdown the UPS after the system has halted.\r
165 (Note: Depending on the UPS this could take a minute or two).  Thus when the \r
166 power returns the UPS will come back on and the system will power up (providing\r
167 your atx bios supports powerup).  \r
169 Apcupsd for most distributions modifies the existing halt script.  Rather than\r
170 that route we are making a separate script called UPSdown.\r
172 Using a text editor create UPSdown as follows in /etc/init.d:\r
174 #!/bin/sh\r
175 # Begin /etc/init.d/UPSdown\r
177 # Script to shutdown UPS after computer shutdown\r
179 # Symlink in rc0.d after umounting filesystems\r
182 # See if this is a powerfail situation\r
183 if [ -f /etc/apcupsd/powerfail ]; then\r
184         echo\r
185         echo "APCUPSD will now power off the UPS"\r
186         echo\r
187         /etc/apcupsd/apccontrol killpower       \r
188         echo\r
189         echo "Verify the UPS shuts down or turn off the system"\r
190         echo\r
191 fi\r
193 # End /etc/init.d/UPSdown\r
196 =========================\r
197 3.2.3 Symlink the scripts\r
198 =========================\r
199 The apcupsd daemon should be started fairly soon in the boot cycle to provide\r
200 protection.  Using three digit symlinks, S200 for my system seems appropriate.\r
201 Use your own judgement here.\r
203 Stopping the daemon should occur fairly late.  I use K990.\r
205 The UPSdown script should be run immediately prior to the halt script.  If\r
206 halt is S999 then UPSdown would be S998.\r
208 Run the following:\r
210 cd /etc/init.d &&\r
211 chmod 754 apcupsd UPSdown &&\r
212 cd ../rc0.d &&\r
213 ln -s ../init.d/apcupsd K990apcupsd &&\r
214 ln -s ../init.d/UPSdown S998UPSdown &&\r
215 cd ../rc1.d &&\r
216 ln -s ../init.d/apcupsd K990apcupsd &&\r
217 cd ../rc2.d &&\r
218 ln -s ../init.d/apcupsd S200apcupsd &&\r
219 cd ../rc3.d &&\r
220 ln -s ../init.d/apcupsd S200apcupsd &&\r
221 cd ../rc4.d &&\r
222 ln -s ../init.d/apcupsd S200apcupsd &&\r
223 cd ../rc5.d &&\r
224 ln -s ../init.d/apcupsd S200apcupsd &&\r
225 cd ../rc6.d &&\r
226 ln -s ../init.d/apcupsd K990apcupsd\r
229 ================\r
230 4. Configuration\r
231 ================\r
233 Our generic configure in  3.1 above placed the configuration file in\r
234 /etc/apcupsd.  This file is called apcupsd.conf.  Pleae consult the apcupsd\r
235 manual to determine the settings for your system and APC model UPS.\r
237 ================\r
238 5. Conclusion\r
239 ==============\r
240 The above steps were an attempt to have you quickly provide APC UPS power\r
241 protection to your system using Apcupsd software.  The software allows the\r
242 individual user a lot of options depending on his needs and desires.  For\r
243 example I use the cgi feature to be able to see the status of my UPS from a\r
244 browser.  I use the notification feature to mail the electric company that I\r
245 have loss power.  These and other features along with a description of the\r
246 workings of Apcupsd are fully described in the Apcupsd manual. \r