Hi there,
(sorry, I could not find how to insert code properly, and it is not easy to read - I can edit my post if somebody tells me how to )
I used to use a few scripts on my previous Rpi1 (Xbian) to enable the auto-stop of transmission when the VPN connection gets lost, and restart transmission when the VPN is recovered. However, I cannot manage to make it work on my Rpi2 (OSMC). Could somebody have a look, and let me know if the folder used or code used are not suitable with OSMC ?
Step1: prevent Transmission to start alone
sudo update-rc.d -f transmission-daemon remove
(I get these messages:
insserv: warning: script âK01startSB.shâ missing LSB tags and overrides
insserv: warning: script âstartSB.shâ missing LSB tags and overrides)
Step2: allow only the VPN_IP_@ to be used, by creating a template of the settings.json
sudo cp /etc/transmission/settings.json /etc/transmission/settings_template.json
sudo nano /etc/transmission/settings_template.json
changed line âbind-address-ipv4â: â0.0.0.0â by âbind-address-ipv4â: âVPN_IP_@â
sudo touch /etc/openvpn/up.sh
sudo chmod +x /etc/openvpn/up.sh
sudo nano /etc/openvpn/up.sh
Add:
'#!/bin/sh
/etc/init.d/transmission stop
sed s/IP_ADDRESS/$4/ /etc/transmission-daemon/settings_template.json > /etc/transmission-daemon/settings.json
/etc/init.d/transmission-daemon start
Step4: start the Step3 script only when the VPN is running
sudo nano /etc/init.d/startSB.sh
'#!/bin/sh
sudo openvpn --config /etc/openvpn/MyVPN/US.ovpn --script-security 2 --up /etc/openvpn/up.sh
Thank you very much,
Nikox