Bug 44415 - systemctl does not list services based on init.d/sysv scripts
Summary: systemctl does not list services based on init.d/sysv scripts
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: Lennart Poettering
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-03 02:43 UTC by foudil.newbie+bugzilla.freedesktop.org
Modified: 2016-06-07 10:30 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description foudil.newbie+bugzilla.freedesktop.org 2012-01-03 02:43:30 UTC
Steps to reproduce:
1. On Fedora 16, systemd v37, yum install httpd
2. wait 10 seconds after install complete
3. systemctl list-units --full --no-legend --no-pager --all | grep httpd

Actual results: none

Expected results:
httpd.service  loaded inactive dead  The Apache HTTP Server (prefork MPM)

Additional info:
systemctl show|start|stop|... httpd.service # work well
Comment 1 foudil.newbie+bugzilla.freedesktop.org 2012-01-13 03:29:34 UTC
I should describe the problem further:
systemctl list-units --all should list disabled units also.

Or there should be a way to really list all units: active/inactive and enabled/disabled.
Comment 2 Lennart Poettering 2012-01-13 06:51:15 UTC
Use "systemctl list-unit-files" to list all unit files, even the non-enabled ones.
Comment 3 Alexey Pakseykin 2013-11-11 18:47:13 UTC
Command "systemctl list-unit-files" lists unit files, not service names.

If unit file is parameterized (see openvpn@.service on Fedora 19),
then service unit file != service name.

For example,
systemctl --full list-units --all | grep openvpn
- if service "openvpn@example.com" is enabled, this command will list it;
- if service "openvpn@example.com" is disabled, there will be no output.

I understand that systemd may have no idea how many possible configurations exists for parameterized unit files. However, the inconsistency of seeing service depending on whether it is enabled or disabled is obvious.

There should be a way to list configured services regardless whether they are enabled or disabled. Otherwise the interface for any high-level tool is ambiguous. I've just encountered that SaltStack relies on this (and obviously fails):
https://groups.google.com/forum/#!topic/salt-users/Ll9NagwXIsk
Comment 4 Alexey Pakseykin 2014-04-16 19:48:39 UTC
== ANOTHER EXAMPLE ==

Command `systemctl list-units` does not list _stopped_ init.d/sysv services.

In this example it is `jenkins` but can be any init.d/sysv script:

# 1. Start service and try to list:
sudo systemctl start jenkins
systemctl list-units | grep jenkins
# bug: no output

# 2. Stop service and try to list:
sudo systemctl stop jenkins
systemctl list-units | grep jenkins
jenkins.service
# 

The `jenkins` script for this example can be installed in a couple of commands:
http://pkg.jenkins-ci.org/redhat/

== VERSION ==

> yum info systemd
...
Name        : systemd
Arch        : x86_64
Version     : 208
Release     : 16.fc20
...
Comment 5 Alexey Pakseykin 2016-04-28 14:48:02 UTC
I just want to update this bug.

There are:
- different commands suggested to list services
     - systemctl list-units
     - systemctl list-units --all
     - systemctl list-unit-files
     - systemctl list-unit-files --all
- commands assumed different contexts:
     - pure systemd unit files
     - init.d/sysv scripts
- commands assumed different state of the service:
     - started

- various old versions of systemd + Fedora


While I cannot verify the history, I can confirm there is at least one method which allows listing both init.d/sysv 

The original description mentioned `httpd` service on F16 -
this was long time ago and `http` could still be a init.d/sysv service.

However
Comment 6 Alexey Pakseykin 2016-04-28 15:10:48 UTC
PLEASE ignore comment 5 - it was incomplete.
Somehow UI designers think if human press <space> while focus is on the "Save Changes" button, it means I want to submit my changes irreversibly. And the focus can unintentionally set there via <tab> (and not add an indention). Sigh... :\

So, rewritten and pasted from normal text editor...

I just want to update this bug.

There are:
- different commands suggested to list services
     - systemctl list-units
     - systemctl list-units --all
     - systemctl list-unit-files
     - systemctl list-unit-files --all
- different service nature:
     - pure systemd unit files
     - init.d/sysv scripts
- different state of the service:
     - started
     - stopped
     - enabled
     - disabled
- various old versions of systemd + Fedora:
     - ...

As you can see, the test space is huge and may easily confuse without explicitly stating all conditions.

Let's simplify. All we need is a way to list a service:
- regardless of its nature
- regardless of its state

We also don't care much about history (previous versions).

I tested my example from Comment 4 using `jenkins` again on my Fedora 23 x86_64 with `systemd-222-14.fc23.x86_64`.

Because I used `jenkins` (which uses init.d/sysv script) I don't know how good any command above lists pure systemd unit files.
My experience simply says there is no problem with unit files. I even renamed this bug specifically for init./sysv scripts.

*** The result is: NONE of the commands above were able to list it in _DISABLED_ mode. ***

The closest to success was `systemctl list-units --all` - it was able to list `jenkins` init.d/sysv service in `enabled`, `stopped`, `started` modes, but failed on `disabled`. However, note that `systemctl status jenkins` actually detected the service:
  systemctl status jenkins
 ● jenkins.service - LSB: Jenkins Continuous Integration Server
    Loaded: loaded (/etc/rc.d/init.d/jenkins)
    Active: inactive (dead)
      Docs: man:systemd-sysv-generator(8)
 
 Apr 28 18:45:13 projector systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
 Apr 28 18:45:13 projector runuser[1670]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
 Apr 28 18:45:14 projector runuser[1670]: pam_unix(runuser:session): session closed for user jenkins

Other commands did even worse:
- `systemctl list-unit-files --all` couldn't detect stopped `jenkins`
- and any command without `--all` switch does not detect `jenkins` at all (this might be correct behaviour).
Comment 7 Lennart Poettering 2016-06-07 10:30:52 UTC
Current systemd versions (v230++) will also list generated units files now, which hence means SysV services show up too in "systemctl list-unit-files", too.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.