Tool to parse systemd unit files

Martin Steigerwald martin at lichtvoll.de
Wed Sep 25 07:58:24 BST 2019


Hi Joost, hi

to @all: Thanks for the efforts to come up with a systemd unit file
parser.

Joost van Baal-Ilić - 25.09.19, 08:19:40 CEST:
> On Mon, Sep 23, 2019 at 09:59:01PM -0300, Jesse Smith wrote:
> 
> <snip>
> 
> > 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.
> Slightly related; might come in handy here: I still really like the
> idea behind Petter Reinholdtsen's init-d-script, as shipped with
> sysvinit's sysvinit-utils since 2013.  It's an interpreter for short
> and simple init.d scripts, aiming to reduce redundant code in
> /etc/init.d/.  See
> http://people.skolelinux.org/pere/blog/Debian_init_d_boot_script_examp
> le_for_rsyslog.html for an instructive example; its manpage is online
> at
> https://manpages.debian.org/init-d-script .

I really like this, as an init script I made for my fio package, to
complement the systemd service file just looks like this:

% cat /etc/init.d/fio 
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          fio
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Flexible I/O Tester as service
# Description:       Runs fio as a service to that fio clients can connect
#                    to it
### END INIT INFO

# Author: Martin Steigerwald <[…]>

DESC="Flexible I/O Tester as service"
DAEMON=/usr/bin/fio
DAEMON_ARGS='--server --daemonize /run/fio.pid'
PIDFILE='/run/fio.pid'

In a sense this looks quite similar to a systemd service file already.

And you can still override for example the "start" action by provide a
function with a well defined name.

Thanks,
-- 
Martin






More information about the Debian-init-diversity mailing list