How to set up OpenVPN and Transmission to start at boot on CentOS 6?
5
votes
2
answers
2776
views
I'm trying to set up Transmission with OpenVPN on a headless server running a minimal install of CentOS 6.10, and ideally these would start when I boot the system.
I'm able to get everything to run by following the steps [here](http://www.naspberrypi.com/openvpn.html) and [here](http://www.naspberrypi.com/openvpn-transmission.html) — but that only works when running the script (
vpn.sh
, as per the two tutorials) manually. That script looks like this:
#!/bin/sh
sudo openvpn --cd /etc/openvpn --config /etc/openvpn/conf.ovpn --script-security 2 --up /etc/openvpn/up.sh
I might add that in addition to OpenVPN and Transmission, I also have [this Telegram bot](https://github.com/pyed/transmission-telegram) that should start after all else is up, so my up.sh
file also has one more line at the end and looks like this:
#!/bin/sh
/etc/init.d/transmission-daemon stop
/bin/sed s/IP_ADDRESS/$4/ /var/lib/transmission/.config/transmission/settings_template.json > /var/lib/transmission/.config/transmission/settings.json
/etc/init.d/transmission-daemon start
/etc/init.d/transmission-telegram start
Ideally, I'd be able to do something a bit more like what [this post](https://askubuntu.com/q/583679) outlines, though I'm not particularly picky about whether all the traffic goes through the VPN or if only the torrent traffic does:
1. Start OpenVPN at boot (after networking is up);
2. If the VPN connection goes through, configure Transmission to run through it;
3. If that goes through, run Transmission (and the Telegram bot);
4. If at any time the VPN goes down, also bring Transmission (and the Telegram bot) down gracefully.
I tried following the steps outlined in that post, and for some reason I just can't get the event transmission-vpn-up
to happen — triggered by the route-up.sh
script in the tutorial — and always get initctl: Event failed
. I'm not able to emit the event either by following the steps in the post, nor by passing the contents of the script manually to the command line. route-up.sh
, as per the post on Ask Ubuntu, looks like this:
#! /bin/bash
/sbin/initctl emit transmission-vpn-up VPN_GATEWAY=$route_vpn_gateway LOCAL_IP=$ifconfig_local
If I pass the contents of down.sh
to the command line, though, I get no such error:
/sbin/initctl emit transmission-vpn-down
Tried passing both with sudo
and without it.
Is there a simple way for me to set this whole thing up? Am I missing something in particular with emit
ting the transmission-vpn-up
specified in the other tutorial on AU, y'know, given that it's a tutorial for Ubuntu and not CentOS?
Alternatively, would it be easier to just make vpn.sh
(the first chunk of code in this post) run at boot? It would be as neat or graceful if the VPN goes down, but it'd do the trick.
---
**Quick Update:**
[The tutorial on Ask Ubuntu I mentioned above](https://askubuntu.com/a/583680) , particularly in the /etc/init/transmission-up.conf
is trying to use /usr/sbin/ufw
, which I don't have in CentOS — hence the original Event failed
error message. I temporarily commented out those bits, and now I don't have any error messages.
However, even without any error messages and with the VPN up and running, it seems like something else is failing because Transmission never starts... any hints on where I could look?
Asked by Marcy
(63 rep)
Apr 24, 2019, 11:16 AM
Last activity: May 6, 2019, 01:37 PM
Last activity: May 6, 2019, 01:37 PM