Created
December 16, 2011 14:10
-
-
Save jonhoo/1486171 to your computer and use it in GitHub Desktop.
Script for connecting to VPN using OpenVPN configs
This file contains 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 | |
if [ -n "$1" ]; | |
then | |
if [ -e "$HOME/.openvpn/$1.ovpn" ] | |
then | |
sudo openvpn --cd ~/.openvpn --config "$1.ovpn" --daemon | |
STATUS=$? | |
if [ $STATUS -eq 0 ] | |
then | |
echo "Connected to VPN network $1" | |
exit 0; | |
else | |
echo "Could not connect to VPN network $1" 1>&2 | |
exit $STATUS | |
fi | |
else | |
echo "No VPN config named $1 found" 1>&2 | |
exit 2 | |
fi | |
else | |
echo "Usage: $0 <profile>" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment