From efe4824546d5db6adfdcb44300ca232bb0229cb3 Mon Sep 17 00:00:00 2001 From: kumy Date: Thu, 3 Nov 2016 20:18:16 +0100 Subject: [PATCH] Fix detecting ipv4 tunnel address The original grep expression will fails if server support also ipv6. ``` qbittorrent | + ip addr show tun0 qbittorrent | + grep inet qbittorrent | + awk { print $2 } qbittorrent | + local_vpn_ip=10.2.10.6 qbittorrent | fe80::faac:xxx:xxx:xxx/64 qbittorrent | + pia_client_id_file=/etc/transmission/pia_client_id qbittorrent | + transmission_settings_file=/data/transmission-home/settings.json qbittorrent | + port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment qbittorrent | + cat /etc/transmission/pia_client_id qbittorrent | + pia_client_id=6fe581ea5b6273a88ed8421b4ceed454 qbittorrent | + [ -z 6fe581ea5b6273a88ed8421b4ceed454 ] qbittorrent | + curl -d user=xxx&pass=xxx&client_id=6fe581ea5b6273a88ed8421b4ceed454&local_ip=10.2.10.6 qbittorrent | fe80::faac:xxx:xxx:xxx/64 https://www.privateinternetaccess.com/vpninfo/port_forward_assignment qbittorrent | % Total % Received % Xferd Average Speed Time Time Time Current qbittorrent | Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ``` --- transmission/updatePort.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmission/updatePort.sh b/transmission/updatePort.sh index 3c3f276..cf272d5 100755 --- a/transmission/updatePort.sh +++ b/transmission/updatePort.sh @@ -11,7 +11,7 @@ pia_username=$(head -1 $PIA_PASSWD_FILE) pia_passwd=$(tail -1 $PIA_PASSWD_FILE) transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE) transmission_passwd=$(tail -1 $TRANSMISSION_PASSWD_FILE) -local_vpn_ip=$(ip addr show tun0 | grep inet | awk '{ print $2 }') +local_vpn_ip=$(ip addr show tun0 | grep "inet " | awk '{ print $2 }') pia_client_id_file=/etc/transmission/pia_client_id transmission_settings_file=${TRANSMISSION_HOME}/settings.json port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment