cvs commit: hints apcupsd-serial.txt

timothy at timothy at
Thu Feb 20 10:43:15 PST 2003

timothy     03/02/20 13:43:15

  Added:       .        apcupsd-serial.txt
  Initial commit.
  Revision  Changes    Path
  1.1                  hints/apcupsd-serial.txt
  Index: apcupsd-serial.txt
  TITLE:		Apcupsd-serial
  AUTHOR:		John McSwain <jmcswain at>
  	Installing Apcupsd to protect an LFS system using APC UPS connected
  	via serial port.    
  version 1.1 (02/19/2003)
  1 Introduction
  2 Changelog
  3 Software
  4 Installation
    4.1 Generic
    4.2 LFS specific
        4.2.1 Boot script
        4.2.2 Poweroff script
        4.2.3 Symlink the scripts
  5 Configuration      
  6 Conclusion
  1. Introduction
  Apcupsd is useful for controlling American Power Conversion's (APC)
  uninterruptiple power supplies (UPS).  Apcupsd monitors the UPS and during a
  power loss, informs the system users of the failure, and if power is not 
  restored, safely shuts down the system.  The Apcupsd manual (available on line
  at or with the software)
  provides excellent instructions on installing and configuring the software.
  The configure script can identify several standard linux distributions and make
  the correct installation. However, as LFS is by design not standard this hint
  provides the information to protect an LFS system with an APC UPS connected
  via a serial connection using Apcupsd software.
  If you are using an APC UPS that connects via USB please see the hint by
  Bryan Mason <>.
  The installation of Apcupsd is mostly straightforward until "make install" is
  completed. Then the LFS user will see the following series of messages:
  "Unknown distribution
  You have to manually install apcupsd boot script and
  halt script for clean emergency shutdown.
  Please contribute your distribution install to apcupsd team.
  I'm sorry: you are on your own."
  The purpose of this hint is to provide one method of accomplishing the above
  actions to get Apcupsd up and running on the LFS "unknown" distribution.
  2. Changelog
   1.0 Original hint (06/27/01)
   1.1 Updated to current script location (/etc/rc.d/init.d/), two digit symlinks,
      software download location and latest version.	
  3. Software
  The Apcupsd software can currently be found at sourceforge:
  As of this writing the latest stable release is Apcupsd-3.8.6.
  4. Installation
  Obtain the source and unpack it in a suitable place such as /usr/src/.
  Compiler optimizations can be used with Apcupsd.  See Optimization.txt hint
  and the Apcupsd manual for more information.
  4.1 Generic
  Run the following command:
  ./configure --prefix=/usr --sbindir=/sbin
  This is a basic installation.  If you have a smartups and wish to have a web
  interface to the APC unit's status from your web server see the Apcupsd manual.
  You will probably want to run the above commands with additions:
  ./configure --prefix=/usr --sbindir=/sbin \
   --with-cgi-bin=/home/httpd/cgi-bin --enable-cgi
  Now run:
  make &&
  make install
  4.2 LFS specific
  At the end of the make install you will get the messages listed above in the
  introduction.  A bootscript and proper halt script must be manually
  4.2.1 Bootscript
  Use the template script in /etc/rc.d/init.d as a guide to make the boot script.
  cd /etc/rc.d/init.d
  cp template apcupsd
  Now edit the apcupsd file to make the following bootscript:
  # Begin /etc/rc.d/init.d/apcupsd
  # S20 in /etc/rc{2,3,4,5}.d and K95 /etc/rc{0,1,6}.d
  source /etc/sysconfig/rc
  source $rc_functions
  case "$1" in
  		# House keeping if this were a restart from powerfail
  		rm -f /etc/apcupsd/powerfail
  		rm -f /etc/nologin
  		# Start apcupsd
                  echo -n "Starting apcupsd power management ..."
                  loadproc /sbin/apcupsd
                  echo -n "Stopping apcupsd power management..."
                  killproc apcupsd
                  echo -n "Reloading apcupsd power management ..."
                  reloadproc apcupsd
                  $0 stop
                  sleep 1
                  $0 start
                  statusproc apcupsd
                  echo "Usage: $0 {start|stop|reload|restart|status}"
                  exit 1
  # End /etc/rc.d/init.d/apcupsd
  4.2.2 Poweroff script
  This poweroff script is needed to shutdown the UPS after the system has halted.
  (Note: Depending on the UPS this could take a minute or two).  Thus when the 
  power returns the UPS will come back on and the system will power up (providing
  your atx bios supports powerup).  
  Apcupsd for most distributions modifies the existing halt script.  Rather than
  that route we are making a separate script called UPSdown.
  Using a text editor create UPSdown as follows in /etc/rc.d/init.d:
  # Begin /etc/rc.d/init.d/UPSdown
  # Script to shutdown UPS after computer shutdown
  # Symlink in rc0.d after umounting filesystems
  # See if this is a powerfail situation
  if [ -f /etc/apcupsd/powerfail ]; then
          echo "APCUPSD will now power off the UPS"
          /etc/apcupsd/apccontrol killpower       
          echo "Verify the UPS shuts down or turn off the system"
  # End /etc/rc.d/init.d/UPSdown
  4.2.3 Symlink the scripts
  The apcupsd daemon should be started fairly soon in the boot cycle to provide
  protection.  Using the current two digit symlinks, S20 for my system seems
  appropriate.  Use your own judgement here.
  Stopping the daemon should occur fairly late.  I use K95.
  The UPSdown script should be run immediately prior to the halt script.  If
  halt is K99 then UPSdown would be S98.
  Run the following:
  cd /etc/rc.d/init.d &&
  chmod 755 apcupsd UPSdown &&
  cd ../rc0.d &&
  ln -s ../init.d/apcupsd K95apcupsd &&
  ln -s ../init.d/UPSdown K98UPSdown &&
  cd ../rc1.d &&
  ln -s ../init.d/apcupsd K95apcupsd &&
  cd ../rc2.d &&
  ln -s ../init.d/apcupsd S20apcupsd &&
  cd ../rc3.d &&
  ln -s ../init.d/apcupsd S20apcupsd &&
  cd ../rc4.d &&
  ln -s ../init.d/apcupsd S20apcupsd &&
  cd ../rc5.d &&
  ln -s ../init.d/apcupsd S20apcupsd &&
  cd ../rc6.d &&
  ln -s ../init.d/apcupsd K95apcupsd
  5. Configuration
  Our generic configure in  4.1 above placed the configuration file in
  /etc/apcupsd.  This file is called apcupsd.conf.  Please consult the apcupsd
  manual to determine the settings for your system and APC model UPS.
  6. Conclusion
  The above steps were an attempt to have you quickly provide APC UPS power
  protection to your system using Apcupsd software.  The software allows the
  individual user a lot of options depending on his needs and desires.  For
  example I use the cgi feature to be able to see the status of my UPS from a
  browser.  I use the notification feature to mail the electric company that I
  have loss power.  These and other features along with a description of the
  workings of Apcupsd are fully described in the Apcupsd manual. 
Unsubscribe: send email to listar at
and put 'unsubscribe hints' in the subject header of the message

More information about the hints mailing list