Created
October 11, 2021 18:38
-
-
Save movalex/605aadd75ab03a9869fbd56038aa57cc to your computer and use it in GitHub Desktop.
Start VPN Unlimited with Bash script
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
function uvpn() { | |
SECRET=$VPN_SECRET | |
status_vpn=$(scutil --nc list | awk '{if (NR!=1) print$2}' | sed -e 's/[()]//g') | |
if ! [[ $status_vpn ]]; then | |
echo "no VPN settings found" | |
return | |
fi | |
vpnName=$(scutil --nc list | awk 'BEGIN {ORS=" "}; {if (NR!=1) for(i = 7;i <= NF-1; i++) print$i}' | sed -e 's/"//g') | |
vpnID=$(scutil --nc list | awk '{if (NR!=1) print$3}') | |
case "$1" in | |
start) echo "started $vpnName" | |
scutil --nc $1 $vpnID --secret $SECRET;; | |
stop) echo "stopping $vpnName" | |
scutil --nc $1 $vpnID | |
status_vpn=$(scutil --nc list | awk '{if (NR!=1) print$2}' | sed -e 's/[()]//g') | |
echo VPN is $status_vpn;; | |
*) echo VPN is $status_vpn;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment