Init script start/stop sequence

I built a package for j-chkmail. This is a milter using the sendmail milter-API and working together with sendmail or postfix. It runs as a daemon and has an init script in /etc/init.d/.

This is the package: https://build.opensuse.org/package/show?package=jchkmail&project=home%3Avodoo

The problem: j-chkmail daemon must be started before sendmail or postfix (to be available for the MTA when it comes up) and shall be stopped after the MTA.

This is the INFO header:

### BEGIN INIT INFO
# Provides:                     j-chkmail
# Required-Start:               $named $network $remote_fs $syslog
# Required-Stop:                $syslog
# Should-Start:
# Should-Stop: 
# Default-Start:                3 5
# Default-Stop:
# Short-Description:            Start j-chkmail (milter)
# Description:                  Start j-chkmail (milter)
### END INIT INFO

Whatever I put in for “Required-Stop” it is shut down before sendmail.

I found this (rather outdated) note:

The Required-Stop keyword indicates what services must still be running during the shutdown of the service (however, this is currently ignored in SUSE; the reverse order of the Required-Start is used instead).

(From: Cool Solutions: How To Create RPMs and Init Scripts That Are Compatible On Both SUSE Linux and Red Hat Linux)

Is this still true? What can I do to ensure the proper start/stop sequence?

Hi
You might want to look here as your missing some bits in the spec file;
openSUSE:Packaging Conventions RPM Macros - openSUSE

You also need to look at the /etc/init.d/skeleton file Notes on “Required-Start/Should-Start” Probably need postfix or sendmail in here, based on this the install macro will create the opposing shutdown after this service.

Hi

Re-reading the text of the above link a dozen times I think that I finally understood the mechanisms. This seems to work:

%post
%{fillup_and_insserv -n jchkmail jchkmail jgreyd}

As for the init scripts: I found a solution in the insserv manpage. The following info header gives the correct sequence:

### BEGIN INIT INFO
# Provides:                     j-chkmail
# Required-Start:               $named $network $remote_fs $syslog
# Required-Stop:                $remote_fs $syslog
# Should-Start:                 
# Should-Stop:                     
# X-Start-Before:               smtp
# X-Stop-After:                 smtp
# Default-Start:                3 5
# Default-Stop:  
# Short-Description:            Start j-chkmail (milter)
# Description:                  Start j-chkmail (milter)
### END INIT INFO

Thank you for all the help.

Hi
Yes, it is confusing to read, like you I had to read it all numerous times for it to make sense. Glad yo have it sorted :slight_smile:

PS, you might want to look at using speccleaner for your spec files to clean them up. You also need to add some conditions in as it makes some changes to the BuildRequires.

PS, you might want to look at using speccleaner for your spec files to clean them up.

A strange tool, it removes my changelog entries … ???

You also need to add some conditions in as it makes some changes to the BuildRequires.

I don’t know what you mean here. It splits them up into separate lines, but leaves the logic intact otherwise.

Hi
The standard is to have a <specname>.changes file when you do an osc vc you update the changes. You need to then osc add the .changes file.

It changes to pkgconfig(some file) which isn’t recognized for < 1130

For example;


%if 0%{?suse_version} >= 1130 
Requires:       pkgconfig(glib-2.0)
Requires:       pkgconfig(gtk+-2.0)
%else
Requires:       gtk2-devel
Requires:       glib2-devel
%endif

Also watch out for the make install;


%if 0%{?suse_version} >= 1120 
%make_install
%else
make DESTDIR=%{buildroot} install
%endif