Description of problem: With the switch from sysinit to systemd the option to send killpower signal to USV was lost. This option was implemented in halt script located in /etc/init.d/ # See if this is a powerfail situation. if [ -f /etc/apcupsd/powerfail ]; then gprintf "APCUPSD will now power off the UPS!\n" echo /etc/apcupsd/apccontrol killpower echo gprintf "Please ensure that the UPS has powered off before rebooting\n" gprintf "Otherwise, the UPS may cut the power during the reboot!!!\n" echo fi Systemd is still using the old initscript of apcupsd which is not able to handle that option. IMHO we need a new systemd script for apcupsd for handling that. In OpenSUSE 12.3 the same problem was solved in that way https://bugzilla.novell.com/show_bug.cgi?id=785156#c2 The discussion about that problem is located here: https://forums.opensuse.org/showthread.php/479499-apcupsd-and-systemd-killpower-issues Is there a chance to get a similar solution? In Cauldron for upcoming Release start and stop for apcupsd is still handled the old way. Reproducible: Steps to Reproduce:
Here is an additional Link which might be helpfull. A patch how it is handled by Fedora / Redhat https://lists.fedoraproject.org/pipermail/scm-commits/2011-June/615180.html
Assignee: bugsquad => luigiwalser
General systemd support for apcupsd (apcupsd.service) could be handled the same way as Redhat (see attachment grabbed from apcupsd-3.14.13-1.fc22 RPM for i686) But there are two different options for implementing killpower option with systemd. 1) Redhat did a bash script "apcupsd_shutdown" for handling killpower option and added that to /lib/systemd/system-shutdown. I'm not sure if that is the best option because it is hard to determine when it is executed by systemd one shutdown of system. The manpage of apcupsd says for killpower option "Power down the UPS in hibernate mode after a 10 second delay." For that short time delay the script should be executed as late as possible during system shutdown but before root filesystem is unmounted, because read access is still needed for that script to check the "powerfail flag" Therefore I would suggest/vote for method two which I grabbed from SuSe forum and adapted for Mageia 4 (see attachment) 2) SuSe user suggested a second service for apcupsd killpower handling with systemd which is added to /lib/systemd/system/ or /etc/systemd/system/ I assume this allows some kind of fine-tuning when the apcupsd killpower call is done during system shutdown (after shutdown.target but before final.target. Source: https://forums.opensuse.org/showthread.php/479499-apcupsd-and-systemd-killpower-issues?p=2496932#post2496932
Created attachment 6131 [details] general systemd support for apcupsd (from apcupsd-3.14.13-1.fc22)
Created attachment 6132 [details] apcupsd_shutdown script (from apcupsd-3.14.13-1.fc22)
Created attachment 6133 [details] killpower service for systemd (from SuSe forum adapted for Mageia)
Thanks for looking into this. Fedora and OpenSuSE's packages both have the same apcupsd_shutdown script, and I would think this is working fine if so. Have you actually confirmed there is a problem with doing it this way? I'm not sure why they didn't submit their systemd support upstream, but whatever we do, we should.
No I haven't tried it with apcupsd_shutdown script. I just tried to figure out, how both methods would theoretically work when I recognized the missing killpower option in Mageia during last USV test. The manpage of apcupsd points out only 10 second delay for killpower signal, what is only true when using apccontrol script (sleep 10 is implemented there). The overall goal should be to send the killpower signal as late as possible during system shutdown in order to give the system the chance to full fill a complete shutdown before USV switches to hibernation mode (and kills the power). Unfortunately I cannot compare both options (shutdown script and killpower service) at the moment because I have no physical access to my server. Of cause I will test both versions next time but that will probably be not before KW 15. Maybe a "systemd expert" can estimate which of both versions will provide more time for the system shutdown process? I assume both versions will work fine with respect to sending the killpower signal but for me it is hard to guess which one is that what we really want with respect to the mentioned goal. I wonder how much the shutdown script was tested because IMHO at least the echo output occurs twice. First in the shutdown script and second in the apccontrol script again which is called from shutdown script. The old sysinit solution in halt script and the killpower service do a direct call to apcupsd instead of using apccontrol. Furthermore apccontrol needs write access to file system when "wall" should word properly. Otherwise only read access is necessary in order to check if /etc/apcupsd/powerfail file exists, because output goes to tty. I'm unsure how to decide, but I definitely agree that we should submit systemd support upstream!
Actually the original sysvinit solution called apccontrol the exact same way the script Fedora/OpenSuSE are using now, as you posted in Comment 0. I'll CC Colin to see if he has any opinion on how this would best be handled.
CC: (none) => mageiaVersion: 4 => Cauldron
So, finally I did some testings with my life system. Both options are working in general, which means that they sent the killpower signal to USV (UPS). During my tests I could never the less observe, that the apcupsd_shutdown script fails with exit code 1. I assume that is, because the call "/etc/apcupsd/apccontrol killpower" is done without '&' and the system shutdown process itself kills the parent process or something like this. When testing the script manually it needed some time until the call to apccontrol returned and then the apcupsd_shutdown script terminated normally with exit code 0. I could not observe that behaviour using the killpower service version, but it is possible that I could just not observe the output on the sceen because it is redirected from systemd internally. With this results there is no special advantage of each of the mentioned options which I could recognise so far. Both are doing the job. I cannot judge which option would fit better according to the system shutdown schedule. At that point someone else has to step into it... (maybe Collin?)
Whiteboard: (none) => MGA5TOO