Hi,

after examining the problem a bit further, I figured out that
"/etc/init.d/ups-monitor" is executed by "/etc/init.d/halt" (which
belongs to the package "initscripts")! I really do not understand how
and why that happened but #670094 already handles that.

I am not really sure but it seems that "/etc/init.d/halt" is not
executed by systemd (which makes sense for me).

So I wrote a systemd-service "/etc/systemd/system/apcupsd-killpower.service"

  [Unit]
  Description=apcupsd: Ordering UPS to kill power (if onbattery/powerfail)
  DefaultDependencies=no
  Before=shutdown.target
  
  [Service]
  ExecStart=/etc/init.d/ups-monitor killpower
  Type=oneshot

  [Install]
  WantedBy=shutdown.target

and did:

  # systemctl enable apcupsd-killpower.service
  Created symlink from 
/etc/systemd/system/shutdown.target.wants/apcupsd-killpower.service to 
/etc/systemd/system/apcupsd-killpower.service

But my first killpower-test gave me errors:

  # journalctl | grep ups-monitor
  Dec 11 18:50:42 server ups-monitor[2780]: apcupsd: Ordering UPS to kill 
power... wall: cannot get tty name: Inappropriate ioctl for device
  Dec 11 18:50:42 server ups-monitor[2780]: wall: /dev/pts/0: No such file or 
directory

So I fixed "/etc/apcupsd/apccontrol" (see #709612):

  # git diff /etc/apcupsd/apccontrol
  diff --git a/apcupsd/apccontrol b/apcupsd/apccontrol
  index 136ff36..b296f82 100755
  --- a/apcupsd/apccontrol
  +++ b/apcupsd/apccontrol
  @@ -62,10 +62,10 @@ fi
   
   case "$1" in
       killpower)
  -       echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
  +       echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}"
          sleep 10
          ${APCUPSD} --killpower
  -       echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | 
${WALL}
  +       echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}"
       ;;
       commfailure)
          echo "Warning communications lost with UPS ${2}" | ${WALL}

(I don't think that "wall" was ever needed so late in the shutdown process).

Please note that I first named the service "ups-monitor.service" which
seemed to conflict with "/etc/init.d/ups-monitor" but I didn't know
how to fix that...

As I am by far a systemd expert I would love to hear some comments on
this solution but at least this works for us. Thank you.

Regards,
 - Darsha


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to