Hi I made this script for myself to connect to Spotify because is not available in my country and i want to share it. It just creates a hidden folder in home folder with a few text files.
You must have installed openvpn if not "sudo apt-get install openvpn"
And this one is to disconnect from the VPN or just use "gksu killall openvpn"
mkdir $HOME/.vpnbook #Creates the directory for all this
wget -r http://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-US1.zip -P $HOME/.vpnbook #Download the ovpn files
wget --recursive --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains website.org --no-parent http://www.vpnbook.com/freevpn -P $HOME/.vpnbook #Download the html to retreive the public password from OpenVPN
unzip -o -d $HOME/.vpnbook $HOME/.vpnbook/VPNBook.com-OpenVPN-US1.zip #Unzip
var=`grep "Password" $HOME/.vpnbook/www.vpnbook.com/freevpn.html` # Retrieve the line with the password from freevpn.html and save it in the var variable, but it gets two lines so let's trim it
var=`echo "$var" | sed -e "1d"` #Trim the variable to one line
var=`echo "$var" | cut -b 1-26 --complement` && var=`echo "$var" | cut -b 9-25 --complement` #Trim the html parameters and only remains the password
echo -e "vpnbook\n$var" >> $HOME/.vpnbook/loginUTF8.conf #Creates the login.conf with the username and the password from the freevpn.html file
iconv -f UTF-8 -t US-ASCII $HOME/.vpnbook/loginUTF8.conf > $HOME/.vpnbook/login.conf #Convert the login.conf file to Windows Unicode to be valid for the openvpn command
sed "s|auth-user-pass|auth-user-pass $HOME/.vpnbook/login.conf|g" $HOME/.vpnbook/vpnbook-us1-tcp443.ovpn > $HOME/.vpnbook/vpnbook-us1-tcp443_new.ovpn #Now the new ovpn file knows where is the login.conf with the username and the password to use. WAS A NIGHTMARE finding out how to use sed with "/" for the directories
gksu -- openvpn --config $HOME/.vpnbook/vpnbook-us1-tcp443_new.ovpn & #Finally connecting. The login.conf must be Windows Unicode format and the ovpn file does not recognize the $HOME variable but the sed command do the job in the upper line
sleep 40 #Wait for the VPN service to connect
notify-send 'Connected to the USA VPN'
Just copy those lines and save it to a text file and rename it to yourtitle.sh and double click on in it to execute them
gksu killall openvpn
#Those files are removed because if the script runs again it will not use the old password
Or open the terminal where the .sh is and type "bash yourtitle.sh"