The installation can be made several different ways depending on what system you are running. The basic procedure involves getting a source distribution, running the configuration, rebuilding, and installing. For RedHat systems, apcupsd is available in binary RPM format as well as source RPM format. Please see RedHat RPM Installation below for more details of the RPM installation. For Microsoft Windows systems, there are two forms of binary install (tar file, and setup.exe). Please see Win32 Installation below for more details of the Windows install.
The basic installation from a tar source file is rather simple:
If all goes well, the ./configure will correctly determine which operating system you are running and configure the source code appropriately. configure currently recognizes the systems listed below in the Operating System Specifics section of this chapter and adapts the configuration appropriately. Check that the configuration report printed at the end of the ./configure process corresponds to your choice of directories, options, and that it has correctly detected your operating system. For systems other than those mentioned above, you may need to do some tweaking.
In general, you will probably want to supply a more complicated configure statement to ensure that the modules you want are built and that everything is placed into the correct directories.
On RedHat, I use the following (all on one line):
CFLAGS="-O2 -Wall" LDFLAGS="-Wall" ./configure --prefix=/usr --sbindir=/sbin --with-cgi-bin=/home/httpd/cgi-bin --enable-cgi
By default, make install will install the executable files in /sbin, the manuals in /usr/man, and the configuration and script files in /etc/apcupsd. In addition, if your system is recognized, certain files such as the startup script and the system halt script will be placed in appropriate system directories (usually subdirectories of /etc/rc.d).
$ which apcupsd
/sbin/apcupsd
$ whereis apcupsd
apcupsd: /sbin/apcupsd /etc/apcupsd /etc/apcupsd.conf /etc/apcupsd.status
/usr/man/man8/apcupsd.8.gz /usr/man/man8/apcupsd.8
# Remount read only anything that's left mounted. #echo "Remounting remaining filesystems (if any) readonly" mount | awk '/ext2/ { print $3 }' | while read line; do mount -n -o ro,remount $line done # See if this is a powerfail situation. # ***apcupsd*** if [ -f /etc/apcupsd/powerfail ]; then # ***apcupsd*** echo # ***apcupsd*** echo "APCUPSD will now power off the UPS" # ***apcupsd*** echo # ***apcupsd*** /etc/apcupsd/apccontrol killpower # ***apcupsd*** echo # ***apcupsd*** echo "Please ensure that the UPS has powered off before rebooting" # ***apcupsd*** echo "Otherwise, the UPS may cut the power during the reboot!!!" # ***apcupsd*** echo # ***apcupsd*** sleep 2d # ***apcupsd*** exit 0 # ***apcupsd*** fi # ***apcupsd*** # Now halt or reboot. echo "$message" if [ -f /fastboot ]; then echo "On the next boot fsck will be skipped." elif [ -f /forcefsck ]; then echo "On the next boot fsck will be forced." fi
The above pertains to RedHat systems only. There are significant differences in the procedures on each system, as well as the location of the halt script. Also, the information that is inserted in your halt script varies from system to system. Other systems such as Solaris require you the make the changes manually, which has the advantage that you won't have any unpleasant surprises in your halt script should things go wrong. Please consult the specific system dependent README files for more details.
Please note that if you install from RPMs for a slave machine, you will need to remove the changes that the RPM install script made (similar to what is noted above) to the halt script. This is because on a slave machine there is no connection to the UPS, so there is no need to attempt to power off the UPS. That will be done by the master.
All the available configure options can be printed by entering:
./configure --help
When specifying options for ./configure, if in doubt, don't put anything, since normally the configuration process will determine the proper settings for your system. The advantage of these options is that it permits you to customize your version of apcupsd. If you save the ./configure command that you use to create apcupsd, you can quickly reset the same customization in the next version of apcupsd by simply re-using the same ./configure command.
The following command line options are available for configure to customize your installation.
For most systems, we recommend the following options:
./configure --prefix=/usr --sbindir=/sbin
and you can optionally build and install the CGI programs as follows:
./configure --prefix=/usr --sbindir=/sbin --enable-cgi --with-cgi-bin=/home/httpd/cgi-bin
CFLAGS="-O2 -Wall" LDFLAGS= ./configure
Or on systems that have the env program, you can do it like this:env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Or for example on the Sun Solaris system, you can use:
setenv CFLAGS -xO2
setenv LDFLAGS -O
./configure
Below, you will find a list of Operating Systems for which we have received installation files:
AlphaDEVICE /dev/tty01In addition, you should ensure serial port lock file in apcupsd.conf is defined as:
LOCKFILE /var/spool/locks
Unlike the Linux systems, the system halt routine is located in /sbin/rc0, so after the make install, please check that this file has been correctly updated.
The start/stop script can be found in:
/sbin/init.d/apcupsd
You can also find the offical Debian packages on the Debian site.
We have no reports of testing this yet on version 3.8.2, but worked fine on 3.8.1
Ensure that you read the distributions/openbsd/README file before running apcupsd. There are some critical differences in how the OpenBSD implemenation operates when the UPS batteries are exhausted. Failure to take this into account may result in the system not being fully halted when power is lost.
rpm -Uhv <release>
where <release> is the release to be installed, and is typically something like apcupsd-3.8.0.i386.rpm (or perhaps apcupsd-3.8.0-pre6.i386.rpm for a pre-release).IMPORTANTIf you are doing a binary RPM upgrade, please remove the previous version of apcupsd because for some unknown reason, the rpm does not always update the halt script. To do the upgrade, use the following two commands:
rpm -e apcupsd
rpm -Uhv <release>
After installation of the binary RPM, please verify carefully that /etc/rc.d/init.d/halt was properly updated and contains new script lines flagged with ***APCUPSD***.
Since there is no standard location for cgi-bin, the rpm will place the binary CGI programs in the directory /etc/apcupsd/cgi. To actually use them, you must copy or move them to your actual cgi-bin directory, which on many systems is located in /home/httpd/cgi-bin.
Please read this before attempting to compile or install the beta software. It contains important information that will make your efforts easier.
If you find bugs, or run into problems that seem to be related to the version of Solaris that you run, please feel free to contact me by email, or through the development mailing list. I'll attempt to help with problems getting the beta running, although I can't promise a quick response.
As always, remember testing UPSes can be hazardous to you system, and, APCUPSD MAY CONTAIN BUGS THAT CAN DAMAGE YOUR SYSTEM AND DATA FILES! You must accept all responsibility for running this software. I'd strongly suggest that you do not run this software on a production system until the final release. An unexpected power-off of a running system can be a disaster. As always, make backups of any critical information before you install this software.
Remember, I told you. I'll listen sympathetically if you lose data, but there will be nothing I can do to help you.
Sincerely,
Carl Erhorn <cerhorn@hyperion.com> <apcupsd-devel@ro.com>
For building the system, I'd suggest that you run the configure and make processes as your normal UNIX user ID. The make install must be run as root. But if your normal ID has an environment setup for using the c compiler, it's simpler to do that than setup root to have the correct environment.
If you have the Solaris workshop compilers instead of the GCC or EGCS compilers, edit the configure script, find the PATH=... statement, and comment it out. Also comment out the following line where the new path is exported. NOTE: these are not necessary if you have beta3 or higher.
Whichever compiler you do have, please insure that you can execute the compiler from the command line before running configure. If you do not have an environment setup to run the compiler first, configure will fail.
Your normal UNIX user ID must own the source tree directories, and you must have the normal development tools in your path. This includes make, the compiler, the M4 preprocessor, the linker, and ar or ranlib. If the user you are logged in as can compile and link a c program from a source file, then you have all the required tools available.
For the Solaris beta, you are required to install the executables in the /sbin directory. This will probably remain true, as during shutdown, Solaris will unmount almost everything except the root directories. Since the ability to power the UPS off requires access to the executable programs, they need to be in a directory that will never be unmounted. And since they should also be in a directory that normal users cannot get into, /sbin is the perfect choice. If you have a problem with this, and have a suggestion on another way to solve the problem, please let me know.
The way to setup the /sbin directory as the executables directory is to pass configure the '--sbindir=/sbin' argument (without the quotes, of course). No other arguments should be required, and your setup and platform should be detected automatically by configure.
Once you have run configure, you will need to do a 'make'. Once the make has completed with no errors, you must su to root to complete the install. After the su, you may not have a path to the make program anymore. In that case, you should do the 'make install' step as:
/usr/ccs/bin/make install
Once the install completes, you must edit the /sbin/rc0 script as detailed below, then exit from the su'ed shell.In order to support unattended operation and shutdown during a power failure, it's important that the UPS remove power after the shutdown completes. This allows the unattended UPS to reboot the system when power returns by repowering the system. Of course, you need autoboot enabled for your system to do this, but all Solaris systems have this by default. If you have disabled this on your system, please re-enable it.
To get the UPS to remove power from the system at the correct time during shutdown, i.e., after the disks have done their final sync, we need to modify a system script. This script is /sbin/rc0.
I do not have access to every version of Solaris, but I think this file will be almost identical on every version. You will need to let me know if this is not true.
At the very end of the /sbin/rc0 script, you should find lines just like the following:
# unmount file systems. /usr, /var and /var/adm are not unmounted by umountall # because they are mounted by rcS (for single user mode) rather than # mountall. # If this is changed, mountall, umountall and rcS should also change. /sbin/umountall /sbin/umount /var/adm >/dev/null 2>&1 /sbin/umount /var >/dev/null 2>&1 /sbin/umount /usr >/dev/null 2>&1 echo 'The system is down.'We need to insert the following lines just before the last 'echo':
#see if this is a powerfail situation if [ -f /etc/apcupsd/powerfail ]; then echo echo "APCUPSD will power off the UPS" echo /etc/apcupsd/apccontrol killpower echo echo "Please ensure that the UPS has powered off before rebooting" echo "Otherwise, the UPS may cut the power during the reboot!!!" echo exit 0 fiI have included these lines in a file called rc0.solaris in the distributions/sun subdirectory of the source tree. You can cut and paste them into the /sbin/rc0 file at the correct place, or yank and put them using vi or any other editor. Note that you must be root to edit this file.
You must be absolutely sure you have them in the right place. If your /sbin/rc0 file does not look like the lines shown above, do not modify the file. Instead, email a copy of the file to me, and I will attempt to figure out what you should do. If you mess up this file, the system will not shut down cleanly, and you could lose data. Don't take the chance.
This feature has only been tested with APC SmartUPS models. If you do not have a SmartUPS, you will be one of the first testers to try this feature. Please send me email to let me know if it works with your UPS model, what model you have, and if possible, the event logs located in /etc/apcupsd. I'd be very interested in your results, and would be glad to work with you to get this feature working correctly with all the APC models. A detailed description of the screen output during the shutdown would be very helpful if you see problems.
You will then need to make the normal changes to the /etc/apcupsd/apcupsd.conf file. This file contains the configuration settings for the package. It is important that you set the values to match your UPS model and cable type, and the serial port that you have attached the UPS to. I have used both /dev/ttya and /dev/ttyb with no problems. You should be sure that logins are disabled on the port you are going to use, otherwise you will not be able to communicate with the UPS. If you are not sure that logins are disabled for the port, run the 'admintool' program as root, and disable the port. The 'admintool' program is a GUI administration program, and required that you are running CDE, OpenWindows, or another XWindows program such as KDE.
eeprom com1-noprobe=true or eeprom com2-noprobe=truedepending on which com port your UPS is attached to. Then sync and shutdown the system normally, reattach the UPS, and reboot. This should solve the problem.
At this point, you should have a complete installation. The daemon will load automatically at the next boot. Watch for any error messages during boot, and check the event logs in /etc/apcupsd. If everything looks OK, you can try testing the package by removing power from the UPS.
As a beta tester, your input is very helpful in solving problems with the package, and providing suggestions and future directions for the development of the package. We are striving to provide a useful package that works across all platforms, and welcome your feedback.
Best regards, and thanks for your interest and help, The Apcupsd Development Team.
If you wish to build from the source, and if you have CYGWIN version 1.3.1-1 and GCC 2.95.3-4 installed, it is possible to build the Win32 version of apcupsd. Note, apcupsd version 3.8.0 as distributed was built with CYGWIN version 1.1.2 but works fine when built and run with CYGWIN 1.1.5. Version 3.8.2 is built with CYGWIN version 1.3.1-1. Please don't try any other versions of CYGWIN as there were known problems. Unfortunately, building apcupsd from source on CYGWIN 1.3.1-1 is six times slower than building it on version 1.1.2, and the CYGWIN developers were not very helpful to resolve this problem (several CYGWIN users were particularly kind). The slow build speed does not seem to translate directly into a slower apcupsd. apcupsd version 3.8.2 requires the pthreads code in CYGWIN 1.3.1-1, so there is no possibility to use the older, faster version of CYGWIN.
To date, the Win32 version has only been build on a Win98 SR2 system with the above CYGWIN environment and all the available CYGWIN tools loaded. In addition, the builds were done running under the bash shell. As time permits, we will experiment with other environments, and if any of you do build it from source, please let us know. The current Win32 build was done with the following CYGWIN packages loaded:
ash-20010425.tar.gz autoconf-2.13-2.tar.gz automake-1.4-3.tar.gz bash-2.05-2.tar.gz binutils-20010425-2.tar.gz bison-1.28-1.tar.gz byacc.tar.gz bzip2-1.0.1-6.tar.gz clear-1.0.tar.gz cpio-2.4.2.tar.gz cygwin-1.3.1-1.tar.gz dejagnu-20010117-1.tar.gz diff.tar.gz expect-20010117-1.tar.gz extralibs-dev-20001007.zip extralibs-src-20001007.zip file-3.33-1.tar.gz fileutils-4.0-3.tar.gz findutils.tar.gz flex-2.5.4-1.tar.gz gawk-3.0.4-1.tar.gz gcc-2.95.3-4.tar.gz gdb-20001125-1.tar.gz gimp-src-20001226.zip glib-dev-20001226.zip glib-src-20001226.zip gperf.tar.gz grep-2.4.2-1.tar.gz groff-1.16.1-1.tar.gz gtk+-dev-20001226.zip gtk+-src-20001226.zip gzip-1.3-1.tar.gz less-358-3.tar.gz libpng-1.0.6-1.tar.gz m4.tar.gz make-3.79.1-3.tar.gz man-1.5g-2.tar.gz mingw-20010424-1.tar.gz mt-1.9.1-src.tar.gz mt-1.9.1.tar.gz newlib-man-20001118.tar.gz patch-2.5-2.tar.gz regex-4.4.tar.gz sed-3.02-1.tar.gz sh-utils-2.0-2.tar.gz shellutils.tar.gz tar-1.13.19-1.tar.gz texinfo-4.0-4.tar.gz textutils-2.0-1.tar.gz time.tar.gz vim-5.7-4.tar.gz w32api-20010424-2.tar.gz
We recommend that you run the ./configure command with the following options:
./configure -prefix=/apcupsd -sbindir=/apcupsd/bin \ -sysconfdir=/apcupsd/etc/apcupsd --with-pid-dir=/apcupsd/etc/apcupsd \ --mandir=/apcupsd --with-cgi-bin=/apcupsd/etc/apcupsd/cgi \ --enable-pthreadsAfter which, you can do a:
make depend make
Unlike the Unix version where it is automatic, you must do the "make depend". And to install apcupsd, do:
make install
During linking of popup.exe and apcupsd.exe, the following warning message is printed:
/USR/BIN/ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000This warning causes no harm. If there is some CYGWIN guru out there who knows how to eliminate this error, please contact me at: kern@sibbald.com.
Finally, you should follow the installation instructions in the Win32 Installation section of this document, skipping the part that describes unZipping the binary release.