Created
April 12, 2016 14:46
-
-
Save EkkoG/a2abec6e8d0929128e17203779b40557 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
#!/bin/bash | |
currentInterface=$(networksetup -listnetworkserviceorder | \ | |
awk -F'\\) ' '/\(1\)/ {print $2}') | |
state=$(networksetup -getwebproxy wi-fi | grep "No") | |
HTTP_PORT=6152 | |
SOCK_PORT=6153 | |
if [ -n "$state" ]; then | |
echo "Turning on proxy" | |
networksetup -setsecurewebproxy $currentInterface 127.0.0.1 $HTTP_PORT | |
networksetup -setwebproxy $currentInterface 127.0.0.1 $HTTP_PORT | |
networksetup -setsocksfirewallproxy $currentInterface 127.0.0.1 $SOCK_PORT | |
networksetup -setwebproxystate $currentInterface on | |
networksetup -setsecurewebproxystate $currentInterface on | |
networksetup -setsocksfirewallproxystate $currentInterface on | |
else | |
echo "Turning off proxy" | |
networksetup -setwebproxystate $currentInterface off | |
networksetup -setsecurewebproxystate $currentInterface off | |
networksetup -setsocksfirewallproxystate $currentInterface off | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment