Created
January 28, 2016 15:24
-
-
Save wklken/e7ce36d058e58e6503a7 to your computer and use it in GitHub Desktop.
keyboard maestro + goagentx, switch wifi connection between office(need proxy) and home(use goagentx). `do shell script "/Users/ken/bin/switch_net" user name "xxxx" password "xxxx" with administrator privileges`
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 | |
# 在公司 | |
if [ "$(networksetup -getairportnetwork en1 | awk '{print $4}')" = "Office" ]; then | |
# 先关闭 Wi-Fi 的所有代理设置 | |
sudo networksetup -setwebproxystate Wi-Fi off | |
sudo networksetup -setsocksfirewallproxystate Wi-Fi off | |
sudo networksetup -setautoproxystate Wi-Fi off | |
# 打开代理的 autoproxy ,设置为公司的 pac | |
sudo networksetup -setautoproxyurl Wi-Fi http://xxxxx/proxy.pac | |
sudo networksetup -setautoproxystate Wi-Fi on | |
# 不在公司 | |
else | |
# 先关闭 Wi-Fi 的所有代理设置 | |
sudo networksetup -setwebproxystate Wi-Fi off | |
sudo networksetup -setsocksfirewallproxystate Wi-Fi off | |
sudo networksetup -setautoproxystate Wi-Fi off | |
#打开代理的 autoproxy ,设置为电脑本地的 pac | |
sudo networksetup -setautoproxyurl Wi-Fi http://127.0.0.1:9999/proxy.pac | |
sudo networksetup -setautoproxystate Wi-Fi on | |
osascript -e ' | |
tell application "GoAgentX" | |
toggle proxy mode to use pac | |
end tell' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment