[systemd-devel] systemctl is-enabled...

Lennart Poettering lennart at poettering.net
Mon Mar 7 15:57:29 PST 2011

On Mon, 07.03.11 22:13, Andrey Borzenkov (arvidjaar at mail.ru) wrote:

> > For the latter we generate a warning currently, telling the user that
> > the service has no [Install] section.
> >
> >> Am I missing something? Is there a different command that should be used?
> >> It seems a more full implementation would parse the dependency graph for
> >> either the current or given target, and check that the service is wanted
> >> by some part of that.
> >
> > Well, but what is the "current" target? We can have multiple.
> >
> Well, "currently isolated target" - is it good enough? This is close
> enough approximation to run-levels we had before.

What do you mean by that? You compare the current set of started units
with those which would be enabled by isolating the various targets and
then say that the one that matches is the "current target"?

That wouldn't work: just start one additional service after boot and
probably no target would match anymore.

Also, in some cases it's not even unique as there could be multiple
targets you can isolate to achieve the very same result, for example if
two units require each other.

> > And if you boot into single user mode, you probably are still interested
> > to know whether a service is enabled in multi-user.target when [Install]
> > says so.
> >
> Yes, that is what --level option in chkconfig is for. Actually this
> could be conceivable for systemctl as well - systemctl is-enabled
> --target=multi-user.target?

I am not convinced this would really be useful. We should conisder a
system fully dynamic these days: the set of services running is no
longer the the one that has been started on boot, but the sum of all
those which got triggered sometime during the past. And triggers can
even work differently if they are used in conjunction. Hence it is
really difficult to answer questions like "Hey, will this service be
running if I boot into multi-user.target", because the answer is mostly
"Well, depends, if the user started application foo, are plugged in
hardware bar...".

I really don't want to create the impression that we could reliably tell
people if a specific service will be running if they start a specific
target, because it's impossible to do.

Hence my suggestion instead: just look whether some hooks are enabled.


Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list