Make one service dependent on another

Hi,

I am currently running both Transmission-daemon and OpenVPN. Unfortunately OpenVPN connection drops. Is there any way that I can make Transmission-daemon dependent on OpenVPN running, so that if OpenVPN does drop, Transmission-daemon will automatically stop?

Many thanks,
Mark

You can use a systemd drop-in to override the dependencies of transmission without worrying about updates nuking your changes.

Not trivially from the top of my head.

It’s not clear what this means,

If the openvpn service crashes (which in my experience rarely happens), then you can modify systemd to restart it automatically. See here for details.

Otherwise, you need to do something yourself, either using iptables or perhaps a shell script to modify transmission’s settings.json parameter bind-address-ipv4 to the tunnel’s IP address. Alternatively, a shell script to detect that the tunnel is down and then stop transmission.

1 Like

Hi,

Sorry, I wasn’t sure how best to describe it. Yes, the openvpn service crashes.

I saw that post actually. However I don’t want openvpn to run continuously, as I want to run Netflix too.

On a slightly different note, sometimes when I start or stop the openvpn service and use “curl ipinfo.io/ip” to check whether the openvpn service is running properly or not, I get the following error message “curl: (6) Could not resolve host: ipinfo.io”. What does this mean, and is there any way to go about correcting it, to either show the VPN’s IP address or my true IP address?

Thanks,
Mark

That is unusual.

It will only restart if you started it in the first place. If you stop it, it remains stopped.

It looks like a DNS issue. File /etc/resolv.conf should contain the IP address of your DNS resolver. A few recent posters seem to have had DNS problems with openvpn for reasons that are not totally clear, though might be because the VPN servers have been blacklisted by the DNS resolver. If you installed resolvconf, I’d recommend that you remove it and use openresolv instead.

I have a couple of questions. Forgive me if they are rather obvious and straightforward.

How do I find out my DNS resolver? File /etc/resolv.conf contains three IP addresses. How do I know if any of them are my DNS resolver?

Yes I have installed resolvconf. How do I go about removing it?
I take it to install openresolv, I just use “sudo apt-get install openresolv”?

Thanks for your time in helping me.
Mark

File /etc/resolv.conf can contain up to three DNS resolvers. You might have set them yourself in OSMC, in which case you’d probably recognise them; they might have come from the router, which you might (or might not) have configured some time previously; or they might have come from the VPN server when you connect to it.

sudo apt-get purge resolvconf
sudo apt-get autoremove

Yes.