Tool to parse systemd unit files

Jesse Smith jessefrgsmith at
Tue Sep 24 01:59:01 BST 2019

After reading Sam Hartman's comments on the situation with SysV init,
systemd init, and the issues faced with maintaining both, I did some
thinking. In particular regarding the part of Hartman's DPL e-mail where
he mentioned many Debian packages have systemd unit files, but no
equivalent init.d style scripts.

This got me thinking that it would be useful if we had either an
init-agnostic service manager which could work with unit files, allowing
sysvinit, runit, etc to use systemd unit files without depending on the
whole systemd suite... Or a tool that could read systemd unit files and
produce mostly-ready-to-use init.d scripts that could be patched into
Debian packages.

With these two thoughts in mind, I did a little tinkering this past
weekend and wrote a crude library which parses systemd unit files to
find the key bits of information (dependency information, commands to
run when starting/stopping services) and put together a little demo program.

Right now the program is very very simplistic and crude. (Really really
crude.) But it will search the system for systemd unit files, load them
all into memory, and work out the dependencies for each unit file. This
evening I got it to the point where it'll recursively find dependencies
for a given unit. With a few small modifications it will run a unit's
dependencies followed by the unit itself.

I'm trying to write the code in a way which will allow it to be used as
a library that could portentially be used in multiple applications. Such
as a systemd-to-init.d converter or a service manager that gets launched
by PID 1 and runs in the background.

The code hasn't been uploaded yet (did I mention it's still very crude?)
but it's functional on my Debian system and I'm curious if anyone else
is interested in exploring these types of applications or would find
them useful. That'll help me direct my attention on what this library of
functions can do and the demo programs I might make with it.

- Jesse

More information about the Debian-init-diversity mailing list