Help with systemd and fetchmail

I’m running openSuSE 12.3 and use the following e-mail retrieval chain.

fetchmail --port 25–> LMTPrelay --2525–> Dovecot via Dovecot’s lmpt listener.

I need to start these services in reverse order. Dovecot then LMTPrelay then fetchmail. This is to prevent fetchmail from retrieving messages when the post-fetchmail chain is not yet working. This is simply a precaution as fetchmail will not flush the retrieved e-mail if there are errors in the hand-off. BTW LMTPrelay classifies messages as ham or spam using spambayes.

I want to do this by editing the after line in fetchmail.service to include LMTPrelay.service and in LMTPrelay.service to include dovecot.service.

The problem is I can’t find fetchmail.service or spambayes.service. systemctl status indicates that they are both started using init scripts.

So, can I specify the order that systemd runs init scripts or must I create custom service units for fetchmail and LMTPrelay? Note that I am surprised that there is no fetchmail.service as I am using 12.3’s version of fetchmail.

Can anyone point me to a good reference on systemd, particularly how it interacts with init scripts?

Systemd uses the sysvinit init scripts if there is no native service unit available (for compatibility reasons).
From “man systemd.service”:

If a service is requested under a certain name but no unit configuration file is found, systemd looks for a SysV init script by the same name (with the .service suffix removed) and dynamically creates a service unit from that script. This is useful for compatibility with SysV. Note that this compatibility is quite comprehensive but not 100%. For details about the incompatibilities see the Incompatibilities with SysV document.

Init scripts normally have a header like this to specify their dependencies:

### BEGIN INIT INFO
# Provides:                     apache apache2 httpd
# Required-Start:               $local_fs $remote_fs $network 
# Should-Start:                 $named $time postgresql sendmail mysql ypclient dhcp radiusd
# Should-Stop:                  $named $time postgresql sendmail mysql ypclient dhcp radiusd
# Required-Stop:                $local_fs $remote_fs $network
# Default-Start:                3 5
# Default-Stop:                 0 1 2 6
# X-Interactive:                true
# Short-Description:            Apache 2.2 HTTP Server
# Description:                  Start the Apache HTTP daemon
### END INIT INFO

You could add the script that should run before to the Required-Start or Should-Start line I guess (look at the Provides line of the other script to see what to add).
AFAIUI Required-Start is equivalent to systemd’s “Requires=” and Should-Start is the same as “After=”.

HTH.

I have not used the applications that you specify. But imagine that you can take an init bash script, move it to a different folder and create a new service file for it to be run. In that real service file, you can specify application or scripts to be run before it gets run. I have done this with dkms, an application you can get from Packman, designed to run applications that need to be recompiled anytime a new kernel version is installed. As supplied by Packman, it did not work in openSUSE 12.2 or 12.3 and so I went through the very steps I suggest here to get it working with systemd. To see what I did have a look here:

DKMS & systemd - How to get Dynamic Kernel Module Support to work in openSUSE 12.1 - Blogs - openSUSE Forums

And to learn more about using systemd, have a look here:

SysdCmd - systemd Command Help/Config Editor - Blogs - openSUSE Forums

And here I took a bash script that no longer ran with systemd and created a service file for it to be run:

systemd and using the after.local script in openSUSE 12.1 - Blogs - openSUSE Forums

You can get it to work if you want and you can see what the problem is, to request a fix, when possible. Interactions between multiple applications not supplied in a working format under systemd may require action from you. You could get what you want if you go through the supplied information and write your own solution.

Thank You,

Thanks wolfi,

I edited the init scripts as you suggested and it gave me the appropriate boot order.