Advertisement
Guest User

portforward

a guest
Feb 16th, 2016
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #! /usr/local/bin/bash
  2. #
  3. # Script based on Eric Rudd's script at https://forums.freenas.org/index.php?threads/guide-setting-up-transmission-with-openvpn-and-pia.24566/page-2#post-174778
  4. #
  5. # Make sure you have a file named piacreds in the same directory as the script
  6. # 1st line of the file is pia username, 2nd password and third client id
  7. #
  8. # to generate a new client id run
  9. #   head -n 100 /dev/urandom | md5sum | tr -d " -"
  10. # in any terminal
  11. #
  12.  
  13. SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  14.  
  15. PROGRAM=`basename $0`
  16. USER=`head -n 1 $SCRIPTDIR/piacreds`
  17. PASSWORD=`head -n 2 $SCRIPTDIR/piacreds | tail -1`
  18. CLIENT_ID=`head -n 3 $SCRIPTDIR/piacreds | tail -1`
  19.  
  20. local_ip=`ifconfig tun0 | grep "inet " | cut -d\  -f2|tee /tmp/vpn_ip`
  21. json=`wget --no-check-certificate -q --post-data="user=$USER&pass=$PASSWORD&client_id=$CLIENT_ID&local_ip=$local_ip" -O - "https://www.privateinternetaccess.com/vpninfo/port_forward_assignment"  | head -1`
  22. PORTNUM=`echo $json | grep -oE "[0-9]+"`
  23. echo $PORTNUM
  24. transmission-remote -p $PORTNUM
  25.  
  26. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement