Setup APCUPSD UPS Utility

apt-get install apcupsd

The system powers off or halts when /etc/init.d/halt is called is governed by setting either HALT=poweroff or HALT=halt in /etc/default/halt.

Unfortunately this line which apcupsd adds to the halt script then gives a problem:

# See if we need to cut the power.
if [ "$INIT_HALT" = "HALT" ] && [ -x /etc/init.d/ups-monitor ]
then /etc/init.d/ups-monitor poweroff
fi

Changing "POWEROFF" to "HALT" ensures that /etc/apcupsd/ups-monitor script runs, which in turn runs /etc/apcupsd/killpower.

Regarding the library error msgs, I encountered these too but realised I hadn't edited /etc/apcupsd/apccontrol to ensure that /var & /usr are remounted ro prior to the shutdown.

Whoops! I meant:

if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]

must be changed by substituting "HALT" in place of "POWEROFF".

ref: http://alma.ch/blogs/bahut/2007/04/apcupsd-in-debian-sarge.html