:: Re: [DNG] does systemd set runlevel…
Página Inicial
Delete this message
Reply to this message
Autor: Tobias Hunger
Data:  
Para: tilt!
CC: dng
Assunto: Re: [DNG] does systemd set runlevel 0 in utmp on shutdown?
Hi tilt!,

Am 29.08.2015 07:53 schrieb "tilt!" <tilt@???>:
> thanks a lot for these hints! Please understand the following questions

not
> directed specifically to you, it's just that I am not very much into

systemd,
> and i appreciate every piece of clarification a lot. I post this here,

because
> this is one forum I know that cares about portability between *different*

init
> systems, and that's just what i would like to ensure for my nodm patch

before
> proposing it anywhere.


Then test it on a couple of systemd systems.

> That makes things difficult: With systemd 217 or later installed,
>
> (1) if utmp is there (it's in POSIX), but the utmp support (being

optional)
> is not there, will utmp simply remain not updated?


My *guess* is that the distribution packaging needs to remove the file. Of
they don't (and the system is stateful, which by far the most are), then
systemd won't care about that file one way or the other and leave it
unchanged.

My arch Linux box still has the systemd-update-utmp.service enabled, so no
idea.

> (2) If the answer to (1) was "yes" then, how to determine if I am dealing

with
> an utmp that is not actually being maintained but just remains there as

sort of
> a compatibility placeholder (again, it's in POSIX)? Check for installed

systemd
> and its version being >= 217?


The systemd version is *not* a good test, considering that (at least) arch
still has that file in systemd 224.

You could check for the update-utmp unit being active if you really cared.

> (3) In the light of questions (1) and (2), does systemd care about POSIX

at all?

My understanding is: Only where it makes sense.

Utmp is a binary file anyway and should not exist in an nice unix system
anyway! Unix philosophy and all that:)

> > I do not think you would need it anyway as systemd will stop the display
> > manager all by itself.
>
> Given the unclarity I tried to express in my previous questions, i admit

that i
> am currently not too confident about that. Just to be on the safe side:


Giving the clean way forward a try before heading down into a rabbit hole
of hacks (as apparently required by lesser init systems) seems worthwhile
to me. Especially considering that you probably do not care for systemd
support anyway.

> (4) Am I right in understanding that the systemd way of determining if a

system
> is in shutdown is to check for a special target "shutdown.target" in the

list
> of "jobs"? Searching the web, I find shellscript examples using the

"systemctl"
> service executable, something along the lines of


I'd check "State" in the output of systemctl status. Or systemctl show for
similar output that is meant for parsing.

> /usr/bin/systemctl list-jobs | egrep -q 'shutdown.target.*start' &&
>        echo "shutting down" ||
>        echo "not shutting down"


Systemd in general has way nicer commands, at least for common things like
this.

> Is there a C API for that, too?


There should be, considering that systemctl gives the state in its
output:-) It is all C.

Best Regards,
Tobias