Created
August 3, 2015 18:35
-
-
Save JonCooperWorks/ca0108288c269977e93b to your computer and use it in GitHub Desktop.
Automatically connect to a random VPN upon connecting to a network. Tested on Fedora 22
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 | |
VPN_NAME="" | |
i=0 | |
VPN_COUNT=5 | |
random=$RANDOM | |
for name in "Germany" "USA" "Canada" "Netherlands" "Sweden" | |
do | |
if (( random % VPN_COUNT == ++i )); then | |
VPN_NAME=$name | |
fi | |
done | |
status=$2 | |
case $status in | |
up|vpn-down) | |
nmcli con up id "$VPN_NAME" | |
;; | |
down) | |
if nmcli con status id "$VPN_NAME" | grep -qs activated; then | |
nmcli con down id "$VPN_NAME" | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment