Created
December 29, 2018 16:11
-
-
Save junderw/10bee41c45ee68771e428e3599088000 to your computer and use it in GitHub Desktop.
NordVPN: JPN or USA to connect to the country you want.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SELECTION=$1 | |
if [ -z "$1" ] | |
then | |
SELECTION="JPN" | |
fi | |
# Default JPN | |
CODE=108 | |
if [[ $SELECTION == "JPN" ]] | |
then | |
CODE=108 | |
fi | |
if [[ $SELECTION == "USA" ]] | |
then | |
CODE=228 | |
fi | |
# The base URL for getting suggestion for the best server for a country | |
BASEURL=https://nordvpn.com/wp-admin/admin-ajax.php | |
QUERY1=action=servers_recommendations | |
QUERY2HEAD=filters={'"'country_id'"': | |
SERVER=`curl -sG $BASEURL -d $QUERY1 -d $QUERY2HEAD$CODE} | jq -r '.[0]["hostname"]'` | |
# Create a temp folder in /tmp | |
TMPFOLDER=$(mktemp -d) | |
cd $TMPFOLDER | |
# Download nordvpn server config files and unzip them, then cd into them | |
wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip &>/dev/null | |
unzip ovpn.zip &>/dev/null | |
cd ovpn_udp | |
# Run openvpn | |
sudo openvpn $SERVER.udp.ovpn | |
# Clean up after openvpn exits | |
rm -rf $TMPFOLDER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment