systemctl without a Unit file ?! - Cool if true

I just ran into something I’d not seen before which might be of interest to anyone running a legacy (SysVinit) app or service.

Just installed an app (logstash from its repos) which does not have a defined systemd Unit file but installed in /etc/init.d/ like any good legacy SysVinit app (and service).

To my astonishment, initially although “systemctl -a | grep logstash” returned nothing, I was still able to enable, start and run logstash as a systemd service

systemctl start|stop|restart|enable\disable logstash

So, I then went about trying to find a logstash Unit file, without success.
Spent a bit of time searching my system, not believing what I was seeing.
I even inspected the contents of the RPM looking for anything that might remotely setup a systemd Unit file without success.

Just now got back word from the logstash developers that indeed… There is no systemd code (they’ve been talking about it, they only have SysVinit and Upstart code).

So, it appears that

systemd now either likely scans the /etc/init.d/ directory and creates/supports an on the fly ephemeral Unit file (not actually creating a permanent file)** or on the fly supports configured SysVinit services with “systemctl” support.

**This could be very useful to know installing a SysVinit app or service, it might be that all you need to do is use a legacy SysVinit installer and don’t need to bother with creating a Unit file.

TSU

On Thu, 13 Aug 2015 20:16:01 +0000, tsu2 wrote:

> systemd now either likely scans the /etc/init.d/ directory and
> creates/supports an on the fly ephemeral Unit file
(not actually
> creating a permanent file)* or on the fly supports configured SysVinit
> services with “systemctl” support.

systemd has long provided backwards compatibility to sysvinit scripts,
IIRC.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2015-08-13 22:16, tsu2 wrote:
> To my astonishment, initially although “systemctl -a | grep logstash”
> returned nothing, I was still able to enable, start and run logstash as
> a systemd service

Yes, this is intentional. It has to be done that way or any services
would not work.

Another trick: start that service, that you know it has no systemd unit
file, via the classic way, “rclogstash”, or if that does not exist, via
“/etc/init.d/logstash”, and you will see at the start a systemd message.
How is it done?

(trick question: I know how it is done :slight_smile: )


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

From

man systemd

systemd is compatible with the SysV init system to a large degree: SysV init scripts are supported and simply read as an alternative (though limited) configuration file format. The SysV /dev/initctl interface is provided, and compatibility implementations of the various SysV client tools are available. In addition to that, various established Unix functionality such as /etc/fstab or the utmp database are supported.

And more in the several man pages.

Thus why; “… if true”.