Skip to content

Commit

Permalink
Updated vpnup check for existing config to account for viscosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Euan Reid committed Nov 27, 2016
1 parent 2761d54 commit 6bed50f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions scripts/ec2gaming-vpnup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@ source "$(dirname "$0")/ec2gaming.header"
echo -n "Connecting VPN (you may see an authentication prompt)... "
IP=$(./ec2gaming-ip.sh)
AUTH=$(realpath "$(pwd)/../ec2gaming.auth")
BACKING_CONFIG=~/Library/Application\ Support/Tunnelblick/Configurations/ec2gaming.tblk/Contents/Resources/config.ovpn
if [ ! -f "$BACKING_CONFIG" ]; then
CONFIG_EXISTS=0

# Find if config exists
if [ "$VPN_CLIENT" = "tunnelblick" ]; then
BACKING_CONFIG=~/Library/Application\ Support/Tunnelblick/Configurations/ec2gaming.tblk/Contents/Resources/config.ovpn
if [ -f "$BACKING_CONFIG" ]; then
CONFIG_EXISTS=1
# the authentication prompt on copy will block, avoids the messy sleep
sed "s#IP#$IP#g;s#AUTH#$AUTH#g" ec2gaming.ovpn.template > "$BACKING_CONFIG"
fi
elif [ "$VPN_CLIENT" = "viscosity" ]; then
grep -R ec2gaming ~/Library/Application\ Support/Viscosity/OpenVPN > /dev/null
if [ $? -eq 0 ]; then
CONFIG_EXISTS=1
fi
fi

# Create config if needed
if [ $CONFIG_EXISTS -eq 0 ]; then
sed "s#IP#$IP#g;s#AUTH#$AUTH#g" ec2gaming.ovpn.template > ec2gaming.ovpn
open ec2gaming.ovpn
echo "Waiting 10 seconds for import..."
sleep 10
else
# the authentication prompt on copy will block, avoids the messy sleep
sed "s#IP#$IP#g;s#AUTH#$AUTH#g" ec2gaming.ovpn.template > "$BACKING_CONFIG"
fi

osascript "ec2gaming-vpnup.$VPN_CLIENT.scpt"

0 comments on commit 6bed50f

Please sign in to comment.