[Soc-coordination] Report 4 - SysV-init file creator from systemd service files

akhil vij akhil.iiit at gmail.com
Sun Jul 15 22:03:13 UTC 2012


Hi Everyone,

I hope you all had a great time at DebConf. I wish I was there in person to
meet the Debian developers and users, but it was not possible this time
around. I hope to attend the next DebConf. Here is my fourth bi-weekly
report :

Fourth Report
============

Project - Sys-V init file creator from systemd service files
============================================================

Status of the project so far :
=============================

A lot of progress happened in the last fortnight. I was able to code the
conversion logic for most of the major systemd options and now we have a
basic version of the converter script working. Here is a list of options
with a short description and their corresponding conversion logic which
were heavily modified in past week :

DefaultDependencies : This option takes a boolean argument. If this option
is set to yes, then a few default dependencies is created for the service
file. No default dependency is kept if this option is explicitly set to no.
Conversion : Syslog and local_fs are kept as default dependencies for most
of the services. Services which have "/usr" on the execution path also have
remote_fs as one of the default dependency.

ExecStopPost : This option takes command line(s) that are executed after
the service was stopped using the commands configured in ExecStop option.
Conversion : Script to save all the commands in a list and then execute
them using the start_daemon() method present in the standard
/lib/lsb/init-functions.

ExecReload : This option takes commands to execute in order to trigger a
configuration reload in the service.
Conversion : This option is used in the implementation of the force-reload
functionality.

TimeoutSec : This option configures the time to wait for start-up and stop
for the service. This takes a value of time (in seconds) as argument.
Conversion : We have a script to check whether a daemon service signals
start-up completion within the above value of time. If not, then the start
up is considered failed and service is stopped. If the action is stop
instead of start and the service does not terminate in the time specified,
then it is terminated forcibly via SIGTERM and after another delay of the
specified time with SIGKILL.

Apart from these Systemd options, some basic error handling was done to
ensure that the converter exits gracefully with lsb-compliant exit codes in
cases of crash, invalid arguments, invalid actions etc. Also the Provides
keyword was added in the generated LSB header. Also the support for the
following functionalities was added :

Reload action : This is an optional action that can be supported by
LSB-complaint init scripts {start, stop, restart and force-reload are
mandatory as per the debian policy [0]. Here is the basic logic behind this
functionality : If ExecReload statement already exists in the service file,
then it will be executed. However, ExecReload is an optional option and is
absent in many service files. In this case, we need to find the service's
PID. We can find the PID by using the pidofproc() method defined in the
standard /lib/lsb/init-functions.

Force-Reload action : This is a mandatory option which has to be supported
by all the init scripts as per the debian policy. It reloads the service's
configuration if the service supports reload (i.e has the ExecReload
option) else it restarts the service.

Logging with the help of log_*_msg() functions defined in
/lib/lsb/init-functions : We use these log_*_msg() methods to log or
display messages. This introduces consistent output in the init scripts.
Also the message follow the syntax defined in the debian policy[1].

Handling specifiers : We added support for handling specifiers like %i, %I,
%f etc. as defined in the Systemd.unit man page[2].

A new dict for .ini parser - For fetching multiple options of the same
name(exec{start,stop}post etc.), we had to create new dict for using with
Python's config parser.

The code is present in my git repository[3].

Future Plans :
==============

Now the main task is to test the converter on as many systemd service files
as possible and use the results to improve the conversion logic. I started
a basic testing this week. Manual generation using conf files from F17. I
also intend to make a proper logging infrastructure to warn users when they
are using systemd options that are incompatible with SysV. There are
certain issues with regard to the LSB header (especially the soft
dependencies like Should-{start/stop}) which I will discuss with the mentor
in the coming week. Once this is settled, I'll prepare a document listing
the conversion logic used in the script, usage etc. We'll then announce an
alpha release of the product on the mailing list and ask the
admins/package-maintainers to use it and share their valuable feedback. In
parallel, I'll be working on the packaging for making this available in the
Debian repo.

Kind Regards,
Akhil Vij

[0] :  http://www.debian.org/doc/debian-policy/ch-opersys.html#s9.3.2
[1] :  http://www.debian.org/doc/debian-policy/ch-opersys.html#s9.4
[2] :  http://0pointer.de/public/systemd-man/systemd.unit.html
[3] :  https://github.com/akhilvij/systemd-to-sysvinit-converter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/soc-coordination/attachments/20120716/8fb11f1a/attachment.html>


More information about the Soc-coordination mailing list