OpenVPN and Transmission

After finding this article http://www.naspberrypi.com/openvpn-transmission.html I decided to take that recommendation and make a couple of minor adjustments so all credit goes there. Ignore my switching to bash, it’s just my preference, most important is adding the daemon flag and pre-down script.

This isn’t a full proof method as transmission will keep running if openvpn receives a hard kill, like signal 9, but it is better than nothing.

So following the recommendations in the above article, I created a simple shell script that calls openvpn for me
File ~/start_vpn
#!/bin/bash set -x sudo openvpn --config /etc/openvpn/big_vpn --daemon --script-security 2 --up /etc/openvpn/up.sh --down-pre --down /etc/openvpn/down.sh

File /etc/openvpn/up.sh
`#!/bin/bash
/etc/init.d/transmission-daemon stop
/bin/sed s/IP_ADDRESS/$4/ /etc/transmission-daemon/settings_template.json > /etc/transmission-daemon/settings.json
/etc/init.d/transmission-daemon start

File /etc/openvpn/down.sh
#!/bin/bash /etc/init.d/transmission-daemon stop