Last active
June 21, 2018 14:38
-
-
Save JoshMcCullough/9d3cfbcc423d74ae9ecde648dc6813c1 to your computer and use it in GitHub Desktop.
Connect to an openvpn server based on a pattern.
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/sh | |
if [ ! $(id -u) = 0 ]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
pattern=$1; | |
match="$(find ~/.openvpn/ -name 'client.ovpn' |grep $pattern |head -n 1)" | |
if [ -z match ]; then | |
echo "No 'client.conf' or directoy found matching pattern '$pattern' within path: $path" | |
else | |
echo "Connecting to VPN using: $match" | |
exec openvpn $match | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes you have VPN configs within
~/.openssh/[connection name]/client.ovpn
.#Usage
sudo ./vpn.sh pattern
Where
pattern
is a regex used to location the VPN connection's folder.