shutdown(8) command. You can modify the behavior by editing the
/etc/apcupsd/apccontrol script, but doing so will make it more com-
plicated to upgrade to the next apcupsd version.
The conditions that trigger the shutdown can be: running time on
batteries have expired (TIMEOUT), the battery runtime remaining
is below the configured value (BATTERYLEVEL), the estimated re-
maining runtime is below the configured value (MINUTES), or the
UPS signals that the batteries are exhausted.
A shutdown could also be initiated if apcupsd detects that the batteries
are no longer functioning correctly. This case, though very unusual,
can happen at any time even if there is proper mains voltage, and
/etc/apcupsd/apccontrol emergency is called.
Just before initiating any shutdown through the apccontrol script,
apcupsd will create the file /etc/apcupsd/powerfail. This file will be
used later in the shutdown sequence to recall apcupsd after syncing of
the disks to initiate a power off of the UPS.
If the /etc/nologin file has not already been created, it will normally
be created during the shutdown sequence to prevent additional users
from logging in (see the NOLOGIN configuration directive).
Even though apcupsd has requested the system to perform a shutdown,
it continues running. If it is a master with slaves, it will inform the
slaves to do a shutdown. They perform their shutdown by calling
/etc/apcupsd/apccontrol remotedown.
• When the system signals apcupsd to do exit, it does so. This is part of
the normal system shutdown (at least on Unix and Linux systems) and
the exact time that apcupsd receives the termination signal depends
on how the shutdown links (usually in /etc/rc.d) are set.
Note that on Windows NT systems, apcupsd apparently continues to
run as a Service even though the machine is “shutdown”.
• During the shutdown of the system after apcupsd has been forced to
exit, one of the last things done by the system shutdown is to call the
halt script, which is usually in /etc/rc.d/halt or /etc/rc.d/init.d/halt,
or possibly in /sbin/init.d/rc.0 depending on your system. If apcupsd
was properly installed, this standard halt script was modified to in-
clude a bit of new logic just before the final halt of the system. It first
tests if the file /etc/apcupsd/powerfail exists, and if it does, it exe-
cutes /etc/apcupsd/apccontrol killpower. It is this last step that
will cause apcupsd to be re-executed with the --killpower option on
the command line. This option tells apcupsd to inform the UPS to
kill the power.
182