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
```
This commit is contained in:
kumy 2016-11-03 20:18:16 +01:00 committed by GitHub
parent 56a074b569
commit efe4824546

View File

@ -11,7 +11,7 @@ pia_username=$(head -1 $PIA_PASSWD_FILE)
pia_passwd=$(tail -1 $PIA_PASSWD_FILE) pia_passwd=$(tail -1 $PIA_PASSWD_FILE)
transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE) transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE)
transmission_passwd=$(tail -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 pia_client_id_file=/etc/transmission/pia_client_id
transmission_settings_file=${TRANSMISSION_HOME}/settings.json transmission_settings_file=${TRANSMISSION_HOME}/settings.json
port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment