Created
May 3, 2018 08:26
-
-
Save zouchao/c49c187d59d20b550c302b43a4fc5aa9 to your computer and use it in GitHub Desktop.
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
function vpn-connect { | |
/usr/bin/env osascript <<-EOF | |
tell application "System Events" | |
tell current location of network preferences | |
set VPN to service "公司l2tp" -- your VPN name here | |
if exists VPN then connect VPN | |
repeat while (current configuration of VPN is not connected) | |
delay 1 | |
end repeat | |
end tell | |
end tell | |
EOF | |
} | |
function vpn-disconnect { | |
/usr/bin/env osascript <<-EOF | |
tell application "System Events" | |
tell current location of network preferences | |
set VPN to service "公司l2tp" -- your VPN name here | |
if exists VPN then disconnect VPN | |
end tell | |
end tell | |
return | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment