I have an upstart script that I am converting to systemd. For this service to start, a certain network interface needs to be available.
This is what I am using in my upstart script:
start on (local-filesystems and net-device-added INTERFACE=tun0)
What's the systemd equivalent?
See https://unix.stackexchange.com/questions/257888/systemd-wait-for-network-interface-to-be-up-before-running-service
You should be able have a slightly broken version of what you had in the upstart script with something like:
systemd should generate the
tun0
'device' file. The only problem is that if thetun0
device isn't created by openvpn quickly enough, your service start will try to 'start'sys-devices-virtual-net-tun0.device
which will result in a timeout failure (by default specified byDefaultTimeoutStartSec
as 90 seconds usually in/etc/systemd/system.conf
). So it might be best to have something to depend on openvpn and then explicitly check for thetun0
device, restarting if it is not found: