Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- ###
- # Network device to be managed.
- # more options exist other than these, run ‘networksetup -listallnetworkservices’ from the terminal
- ###
- wifi=`networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2`
- security unlock-keychain -p 1121 "${HOME}/Library/Keychains/login.keychain"
- if [[ `networksetup -getairportpower $wifi | awk '{ print $4 }'` == "On" ]]; then
- device="Wi-Fi"
- else
- device="Ethernet"
- fi
- if [[ `scutil --proxy | grep ProxyAutoConfigEnable | awk '{ print $3 }'` == "1" ]]; then
- proxyState="enabled"
- else
- proxyState="disabled"
- fi
- if [[ "$proxyState" == "enabled" ]]; then
- echo 1121 |sudo -S networksetup -setautoproxyurl $device " "
- sudo -S networksetup -setautoproxystate $device off
- proxyState="disabled"
- else
- echo 1121 |sudo -S networksetup -setautoproxystate $device on
- sudo -S networksetup -setautoproxyurl $device "http://127.0.0.1:20931/proxy.pac"
- proxyState="enabled"
- fi
- echo "$proxyState"
Advertisement
Add Comment
Please, Sign In to add comment