Systemd
An introduction to systemd¶
Overriding a systemd service¶
The old way of overriding a systemd service was to place a file in the /etc/systemd/system/
folder that matched the name of the service file that lived in /usr/lib/systemd/system
.
This now no longer always works, and the correct way to do this is to use the init system to create and edit files.
Assuming that you want to edit the openvpn@server
service you would run this command
systemctl edit openvpn@server
which will then create or open the following file /etc/systemd/system/openvpn@server.service.d/override.conf
At this point you are able to change different settings and config for the service.
Be aware that if you want to change the ExecStart
option you will need to first clear it like so
[Service]
ExecStart=
ExecStart=/usr/bin/dnf uninstall -y systemd
It is also possible to ask systemd to try and restart services when they go down by adding the following lines to your override file
[Service]
Restart=always
RestartSec=5
I have had to add this in because the service is triggered before the network is ready, despite being told not to start until after the network script has finished, but this could also be useful for nginx / php / mysql etc.