Detecting the init system in use

J Fernyhough j.fernyhough at gmail.com
Sat Dec 16 15:35:03 UTC 2017


On 13/12/17 17:57, Robie Basak wrote:
> 2) Come up with and agree on some other universal way for testing for
> systemd and make that work everywhere. Then we can SRU that test to MAAS
> in Trusty, and fix any other packages in Trusty affected by the
> behaviour change of the original test.

Possibly too simplistic, but /sbin/init itself may be a target for a test:

On a 14.04 system:

$ file /sbin/init
/sbin/init: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.24,
BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2, stripped

On a 16.04 system:

$ file /sbin/init
/sbin/init: symbolic link to /lib/systemd/systemd


Other "pure-systemd" systems (e.g. Arch) use a symlink similar to 16.04
so this should work with later Ubuntu releases too:

$ file /sbin/init
/sbin/init: symbolic link to ../lib/systemd/systemd


J






More information about the Ubuntu-devel-discuss mailing list