[Nut-upsuser] NUT 2.6.3, openSUSE 12.2 : UPS unit not switched off: Fixed

Roger Price roger at rogerprice.org
Sun Oct 28 11:48:14 UTC 2012

On Fri, 26 Oct 2012, Kris Jordan wrote:
> Did you install NUT from a package? Note, 2.6.5 is the current
> version and 2.6.4 had fixed a vulnerability.

I'm using the nut 2.6.3 package included in the openSUSE 12.2 

> Check that your distribution's shutdown script is running 
> 'upsdrvctl shutdown' in the presence of the killpower file

Summary: looks like an openSUSE bug, simple fix available.

OpenSUSE 12.2 has a script /usr/sbin/rcupsd for starting and stopping the 
upsd service. This is a link to script /etc/init.d/upsd which contains:

 	## Special command: Instruct UPS to shutdown.
 	sync &
 	if grep -q '^\[' $UPS_CONFIG ; then
 	    echo -n "Instructing UPS to powerdown "
 	    $UPSDRVCTL_BIN shutdown >/dev/null 2>&1 || rc_failed
 	    echo "No local UPS defined, skipping powerdown "
 	rc_status -v
 	## Special command: Instruct UPS to shutdown, if halt is running
 	## or variable UPSD_POWERDOWN_CONDITION is set and power is failing.
 	## Otherwise silently quit.
 	if test "$RUNLEVEL" = "0" -o -n "$UPSD_POWERDOWN_CONDITION" ; then
 	    if test -n "$POWERDOWNFLAG" -a -f "$POWERDOWNFLAG" ; then
 		exec $0 powerdown

where  UPSDRVCTL_BIN=/usr/lib/ups/driver/upsdrvctl

In addition, file /etc/sysconfig/shutdown contains the configuration 

   # Hook during system shutdown to run extra command
   HALT_POWERDOWN_INSERT="/etc/init.d/upsd try-powerdown"

but when upsd try-powerdown is called it fails silently because $RUNLEVEL 
and $UPSD_POWERDOWN_CONDITION are empty.  upsd powerdown is never called.

I changed the configuration parameter to 
HALT_POWERDOWN_INSERT="/etc/init.d/upsd powerdown", reran command 
SuSEconfig, and tried again but there was no change.  However typing the 
command /etc/init.d/upsd powerdown does shut down the UPS unit.

OpenSUSE 12.2 has fully embraced systemctl and systemd: I tried grepping 
around in the /lib/systemd shutdown specifications, but I cannot find any 
reference to /etc/init.d/upsd powerdown.  This is beginning to look like a 
bug in openSUSE 12.2 which I will report in their forums.

Here is a fix: There is a file /etc/init.d/halt.local which is currently 

  # /etc/init.d/halt.local
  # script with local commands to be executed from init on system shutdown
  # Here you should add things, that should happen directly before shuting
  # down.

I added the lines

  # RP 2012-10-28 Turn off the UPS unit.
  # Needed for automatic system restart when wall power returns.
  echo `date -I` `date +%T` "$0 calls $UPSDRVCTL_BIN shutdown" >> /var/log/halt.local
  $UPSDRVCTL_BIN shutdown

I pulled the plug from the wall and witnessed a server shutdown followed 
10 seconds later by a UPS shutdown.  Pushing the plug back into the wall 
got the system running again.


More information about the Nut-upsuser mailing list