Comment 20 for bug 1634572

Revision history for this message
Alek_A (ackbeat) wrote :

Thanks for the idea, Charl! `/sbin/apcupsd --killpower` indeed kills the power when called not in shutdown sequence. Note that `/sbin/shutdown -H now` and `exit 99` is not necessary here as apccontrol does shutdown anyway.

Your workaround works for me as well! Though I made some additions to proposed /etc/apcupsd/doshutdown script:

#!/bin/bash
#

# Duplicate stdout and stderr to log so we can check it later
exec > >(tee -a /var/log/killpower.log)
exec 2>&1

# create a timestamp
date

# stop apcupsd to prevent simultaneous access to serial port (THIS IS IMPORTANT!)
echo Stopping apcupsd
/bin/systemctl stop apcupsd
# just to be sure
pkill apcupsd

# stop important services to make sure they stopped before power is killed
echo Stopping important services
/bin/systemctl stop pacemaker

echo Killing power
/sbin/apcupsd --killpower

echo Done.
echo

One can modify this script to his/her needs by replacing line `/bin/systemctl stop pacemaker` with what is appropriate for his/her system.

Also make sure that at the point `/sbin/apcupsd --killpower` is executed you have enough time to shut down rest of the system. By default the power will be actually killed in 20 seconds after the call. You can check what timeout is set in your UPS with command

apcaccess|grep DSHUTD
DSHUTD : 120 Seconds

As you see my UPS will kill the power in 120 seconds after `/sbin/apcupsd --killpower` called.

To change this value you should execute `systemctl stop apcupsd`, run `apctest`, then choose '5) Program EEPROM', choose '8) Change shutdown delay', execute `systemctl start apcupsd`.
In manual it is stated that you can also set this value in variable SLEEP in /etc/apcupsd/apcupsd.conf, and then in apctest choose '14) Set EEPROM with conf file values' - but that DON'T work for me, probably it is a bug of apcupsd.