This final step is important if you want to ensure that your system
will automatically reboot when the power comes back on. The actual
code used on the Red Hat version is:
# 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***
fi # ***apcupsd***
The above code must be inserted as late as possible in the halt script. On
many systems, such as Red Hat, all the disk drives were unmounted, then
remountedread-only, thus permitting access to the /etc files andthe apcupsd
executable. If your system does not explicitly remount the disks, you must
remountthem in read-only modein the code that you add. Examples of code
fragments that do this can be found in the distributions/suse subdirectory
of the source.
If you are not able to insert the aboveco de inyour halt script because there
is no halt script, or because your halt script calls the init program as some
Unix systems do, you can either just forget about powering off the UPS,
which means that your machinewill not automatically reb oot after a power
failure, or there is yet another alternative, though not at all as satisfying as
inserting code in the halt script.
Only if you cannot insert the appropriate code in the halt script, when
you start apcupsd, normally from the /etc/rc.d/init.d/apcupsd script, use
the --kill-on-powerfail option. This will cause ap cupsd to program the
UPS to shutoffthe p owerjust before it (apcupsd) do es the system shutdown.
Please note that this is not the most ideal solution. Read on to understand
why.
A very important consideration is that you must set the EEPROMin your
UPS so that it waits a sufficient time for the system to halt before it shuts
off the UPS power. The current value as well as the permitted values for
your UPS can be determined by executing:
apcaccess eeprom
183