"Convert" a SysVinit script to systemd service

I run a Linux system which makes use of both, SysVinit and systemd.
In order to set a dependency between each other (one should only start at boot after the other) I changed the SysVinit script to a systemd service.

1. Old situation:

openhab2 systemd service:
mosquitto SysVinit script:

2. Disable the SysVinit script autostart (here mosquitto) by running as root:

update-rc.d mosquitto remove

> It will remove any link in /etc/rc*runlevel*.d to /etc/init.d./mosquitto

3. Delete the init script:

rm /etc/init.d/mosquitto

> This is importat as systemd checks the init scripts on every boot and then generates systemd services on the fly. Unfortunately these generated services cannot always be used as normal services.

4. Reboot

As mentioned above, you will reboot to a clean system with no automatically generated systemd service.

3. Use your favorite text editor and create the new systemd service file:

Several ways are possible, I decided for:


4. Add content:

Description=Mosquitto MQTT Broker daemon

ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d
ExecReload=/bin/kill -HUP $MAINPID


> Make sure the files marked in red are in place!

5. Enable systemd service:

systemctl enable mosquitto.service 

> This create symlink from /etc/systemd/system/multi-user.target.wants/mosquitto.service to /usr/lib/systemd/system/mosquitto.service

6. Optional: Start your new service and check if it runs

systemctl start mosquitto.service
netstat -lnp | grep mosquitto