On a Ubuntu 20.04.2 TLS server, I have a need to start a service after another one has fully started up. Specifically, the openvpn-server
service creates a tun0
interface with the IP address 10.87.0.1 to which the rinetd
service then binds. So the rinetd
service should only be started after the openvpn-server
service has created that interface.
rinetd
comes with a sysvinit service script /etc/init.d/rinetd
saying:
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
This causes rinetd
to be started during system startup before openvpn-server
has created the interface. It then emits the log message:
rinetd[792]: couldn't bind to address 10.87.0.1 port 873 (Cannot assign requested address)
and does not accept connections until I manually restart it with sudo systemctl restart rinetd
, after which it then runs just fine.
According to sudo systemctl status
the openvpn
server process is run by a systemd service named [email protected]
.
Extending the Required-Start
line in /etc/init.d/rinetd
to say:
# Required-Start: $remote_fs $syslog openvpn-server@server
is duly translated by systemd-sysv-generator
to an additional line
[email protected]
in /run/systemd/generator.late/rinetd.service
.
But systemd ignores that. rinetd
still shows the same log message and malfunction, proving that it is still started before openvpn-server
is up.
How can I get systemd to reliably start the rinetd
service only after the openvpn-server
service has done its part and created the interface?