Linux PIA Control Script
I've created a small (needs work) script to change tunnel locations for Linux OpenVPN command line.
Instructions are inside the script.
#!/bin/bash
# This script is for after OpenVPN and you have followed the PrivateInternetAccess.com instructions
# at https://www.privateinternetaccess.com/pages/client-support/
# it was built on Ubuntu 14.04 but should be generic. It is a combination of PIA instructions and OpenVPN
# Instructions:
# 1. edit your /etc/default/openvpn file and add the following: AUTOSTART="openvpnINUSE"
# 2. create a /etc/openvpn/login.txt file with your credentials PIA username/password one per line.
# 3. Add the following to the ovpn locations you think you will use. I added to all.
# auth-user-pass /etc/openvpn/login.txt
# 4. run the script
# TODO:
# automate everything
IFS='
'
#setting variables
#these 3 are colors for the echo output
red='\e[0;31m'
yellow='\e[1;33m'
NC='\e[0m'
#location of the openvpnConf file
#CHANGEME if you want to use a different location
OPENVPNCONF="/etc/openvpn/openvpnINUSE.conf"
#setup operations
#1 setup the INUSE file
if [ -f $OPENVPNCONF ]
then
echo -e "${yellow}$OPENVPNCONF file Exists!!!${NC} We will continue."
else
touch $OPENVPNCONF
fi
#Normal script operations
# Set the prompt for the select command
PS3="Type a number to select VPN tunnel destination: "
#get a list of locations to VPN to
fileList=( $(find /etc/openvpn -maxdepth 1 -name *.ovpn | xargs -0) )
#populate the select from list
select fileName in "${fileList[@]}" "Quit"; do
if [ -n "$fileName" ]; then
cat ${fileName} > $OPENVPNCONF
fi
break
done
#stop the service before making changes to the file
service openvpn stop
sleep 1
#start the openvpn service back up
service openvpn start
sleep 1
#check the status of the openvpn
service openvpn status
#inform user what vpn you are connected to
echo -e "Now Connected to: ${yellow}$(cat $OPENVPNCONF | grep 1194)${NC}"
Instructions are inside the script.
#!/bin/bash
# This script is for after OpenVPN and you have followed the PrivateInternetAccess.com instructions
# at https://www.privateinternetaccess.com/pages/client-support/
# it was built on Ubuntu 14.04 but should be generic. It is a combination of PIA instructions and OpenVPN
# Instructions:
# 1. edit your /etc/default/openvpn file and add the following: AUTOSTART="openvpnINUSE"
# 2. create a /etc/openvpn/login.txt file with your credentials PIA username/password one per line.
# 3. Add the following to the ovpn locations you think you will use. I added to all.
# auth-user-pass /etc/openvpn/login.txt
# 4. run the script
# TODO:
# automate everything
IFS='
'
#setting variables
#these 3 are colors for the echo output
red='\e[0;31m'
yellow='\e[1;33m'
NC='\e[0m'
#location of the openvpnConf file
#CHANGEME if you want to use a different location
OPENVPNCONF="/etc/openvpn/openvpnINUSE.conf"
#setup operations
#1 setup the INUSE file
if [ -f $OPENVPNCONF ]
then
echo -e "${yellow}$OPENVPNCONF file Exists!!!${NC} We will continue."
else
touch $OPENVPNCONF
fi
#Normal script operations
# Set the prompt for the select command
PS3="Type a number to select VPN tunnel destination: "
#get a list of locations to VPN to
fileList=( $(find /etc/openvpn -maxdepth 1 -name *.ovpn | xargs -0) )
#populate the select from list
select fileName in "${fileList[@]}" "Quit"; do
if [ -n "$fileName" ]; then
cat ${fileName} > $OPENVPNCONF
fi
break
done
#stop the service before making changes to the file
service openvpn stop
sleep 1
#start the openvpn service back up
service openvpn start
sleep 1
#check the status of the openvpn
service openvpn status
#inform user what vpn you are connected to
echo -e "Now Connected to: ${yellow}$(cat $OPENVPNCONF | grep 1194)${NC}"