[Nut-upsuser] NUT on openSUSE 12.3 requires additional systemd service unit

Michal Hlavinka mhlavink at redhat.com
Fri Aug 16 10:35:07 UTC 2013


On 08/15/2013 10:02 PM, Roger Price wrote:
> On Wed, 14 Aug 2013, Michal Hlavinka wrote:
>
>>> The service unit consists of a new file
>>> /etc/systemd/system/ups-delayed-shutdown.service
>>
>> What exactly is this supposed to do?
>
> The proposed service unit fixes an openSUSE 12.3 problem, in which the
> UPS is not powered off on system shutdown.

you mean regular shutdown or power failure shutdown?

>> When system is shutting down because of power failure (and low
>> battery) ups should be powered off with
>> /lib/systemd/system-shutdown/nutshutdown script.
>
> In openSUSE 12.3 there is no directory /lib/systemd/system-shutdown, and
> no script "nutshutdown".  I am guessing that you use Fedora.

That's odd, nutshutdown is part of upstream tarball and should be in 
place when nut is configured to use systemd

http://anonscm.debian.org/gitweb/?p=nut/nut.git;a=tree;f=scripts/systemd;hb=HEAD

I'm using Fedora, but the above is standard systemd directory.

>> That's also the correct location for ups shutdown script.
>
> My original script was in /lib/systemd and I was told in the
> systemd-devel mailing list that home-brew scripts such as mine should
> not be placed there, but in /etc/systemd/system.

yes and no
Your script is service file, so it should be in /etc/systemd/system
BUT this is basic functionality, so if openSUSE uses systemd, then your 
distro nut maintainer should take care of it and place service file in 
/lib/systemd/system

BUT that's for service files, this should not be service file, it should 
be shutdown script and it should be coming from  openSUSE nut package 
with /lib/systemd/system-shutdown as its destination

>> It's executed after everything else. Using Before=umount.target is
>> especially bad bad idea. It's not guaranteed that umount sync can
>> finish in time,
>
> Perhaps I misunderstand your comment, but I'm not worried about
> umount.target running late.  That's not a problem. Finishing early would
> be a problem, but that's what the "Before" and the "Type=oneshot" is
> intended to handle.

Type=oneshot does affect ordering
Before=umount.target simply means you ask UPS to shutdown (with delay) 
before you start umounting disks and syncing changes

> Quote from man systemd.service:     Behavior of oneshot is similar to
> simple, however it is expected that the process has to exit before
> systemd starts follow-up units.

yes, execution of your service file (ups shutdown) will be considered 
completed when the executed binary exits AND will be considered as 
"running" (opposite of "failed" state) despite the process exited. 
Again, it does not affect ordering

> By the way, "Before=umount.target" didn't seem to shock the systemd guys.

"my" systemd guys (2 systemd developers are sitting a few meters from 
me) thinks it's a bad idea.

>> so you can have power down during filesystem sync with all the
>> consequences.
>
> Agreed - systemd executes my openSUSE ups-delayed-shutdown.service at
> the very beginning of the shutdown sequence, and there is a very real
> possibility of the UPS shutdown with its default 20 sec delay occuring
> before the system shutdown.  That is why I have the options

It's just about luck. With network mounted filesystems on servers, 
umount&sync process can take much longer. The longest one I experienced 
with my own eyes was almost two minutes and I guess it was not worst 
case scenario. It's always better to use events than delays, so your 
delay is long enough and is not unnecessarily too long.

Michal

/me is starting 2weeks vacation tmrw, won't be online



More information about the Nut-upsuser mailing list