Skip to content

Instantly share code, notes, and snippets.

@zouchao
Created May 3, 2018 08:26
Show Gist options
  • Save zouchao/c49c187d59d20b550c302b43a4fc5aa9 to your computer and use it in GitHub Desktop.
Save zouchao/c49c187d59d20b550c302b43a4fc5aa9 to your computer and use it in GitHub Desktop.
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