Skip to content

Instantly share code, notes, and snippets.

@jimCresswell
Created October 29, 2015 14:44
Show Gist options
  • Select an option

  • Save jimCresswell/50fba37945c9d4032207 to your computer and use it in GitHub Desktop.

Select an option

Save jimCresswell/50fba37945c9d4032207 to your computer and use it in GitHub Desktop.
#!/bin/bash
status=$1
status=${status:-off}
echo "Will toggle proxy: $status"
IFS=$'\n'; networks=($(networksetup -listallnetworkservices))
for (( i=1; i<${#networks[@]}; i++ )); do
net=${networks[i]}
sudo networksetup -setwebproxystate $net $status
sudo networksetup -setsecurewebproxystate $net $status
done
proxyFlag=false
if [ "$status" == "on" ];
then
proxyFlag=true
fi
echo "Updating maven proxies @ ~/.m2/settings.xml"
sed -i.bak "s/<active>.*<\/active>/<active>$proxyFlag<\/active>/g" ~/.m2/settings.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment