Guest User

set proxy

a guest
Feb 23rd, 2015
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. ###
  4. # Network device to be managed.
  5. # more options exist other than these, run ‘networksetup -listallnetworkservices’ from the terminal
  6. ###
  7. wifi=`networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2`
  8. security unlock-keychain -p 1121 "${HOME}/Library/Keychains/login.keychain"
  9.  
  10. if [[ `networksetup -getairportpower $wifi | awk '{ print $4 }'` == "On" ]]; then
  11. device="Wi-Fi"
  12. else
  13. device="Ethernet"
  14. fi
  15.  
  16. if [[ `scutil --proxy | grep ProxyAutoConfigEnable | awk '{ print $3 }'` == "1" ]]; then
  17. proxyState="enabled"
  18. else
  19. proxyState="disabled"
  20. fi
  21.  
  22. if [[ "$proxyState" == "enabled" ]]; then
  23. echo 1121 |sudo -S networksetup -setautoproxyurl $device " "
  24. sudo -S networksetup -setautoproxystate $device off
  25. proxyState="disabled"
  26. else
  27. echo 1121 |sudo -S networksetup -setautoproxystate $device on
  28. sudo -S networksetup -setautoproxyurl $device "http://127.0.0.1:20931/proxy.pac"
  29. proxyState="enabled"
  30. fi
  31.  
  32. echo "$proxyState"
Advertisement
Add Comment
Please, Sign In to add comment