[Nut-upsdev] RFC: nut and systemd
Michal Hlavinka
mhlavink at redhat.com
Fri May 27 06:25:54 UTC 2011
> > > I'm already working on it. I'll send it to the list, when it's
> > > ready, but just right now it's blocked by bug in systemd.
> >
> > sketch version attached (files in root source directory, paths hardcoded
> > and so
> > on... it's just a sketch version)
>
> already interesting :)
I'll try to prepare better version on Monday.
> btw:
>
> - prefer to use 'nut' instead of 'ups' in .service names
> nut-drivers, nut-server (probably better than 'nut-daemon') and nut-monitor
I was going to ask if nut prefix is better than ups :)
> - also, prefer to mention 'devices' or better 'power devices', instead of
> 'UPS'
will do
> upsmon nor upsd does not support "foreground mode", which is preffered
>
> > (see http://0pointer.de/public/systemd-man/daemon.html ) but it's not
> > that big
> > deal.
>
> use '-D' ?!
yes and no.
Yes, because it makes upsd/upsmon stay in foreground.
No, because it increases verbosity - adds messages upsdebug*(1,...
grep shows cca 270 messages (places).
> > > > As an obvious (and probably the most basic) example with NUT:
> > > > how will you handle the "poweroff" target of the NUT sysV init
> > > > script?
> > > >
> > > > if upsmon -K >/dev/null 2>&1 ; then
> > > >
> > > > if upsdrvctl shutdown ; then
> >
> > just do:
> >
> > printf "#!/bin/sh\n upsmon -K >/dev/null 2>&1 && upsdrvctl shutdown" >
> > /lib/systemd/system-shutdown/upsshutdown
> >
> > and prepare for systemd's almighty grumbling :D There was some futile
> > "discussion" about how wrong is this, but there is no other way doing
> > this
>
> I'm interested in these "futile" discussions ;)
>
> and how the 'upsshutdown' script actually called?
executables in /lib/systemd/systemd-shutdown are called just before shutdown,
no ordering. It's like if you place them in /etc/init.d/halt
Just now, there is only upsshutdown script on my systems, nothing else. I've
already added this script in Fedora 15 where nut uses sysv init script (compat
mode), but halt init script (with ups shutdown hook) is gone.
> with systemd's limited possibilities, the only thing I see is the creation
> of another .service file that Exec it on Stop, and that is executed at the
> very end of the system shutdown?
yes, there is another possibility - nut-shutdown.service and make it required
by halt.target or final.target (not sure right now). But there is no difference
from systemd's POV and (because of "if upsmon -K; then..." you'd still need
some script and because official place for helper script is in /usr/... which
could be already umounted... it's not better way.
More information about the Nut-upsdev
mailing list