56 lines
1.8 KiB
Bash
56 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
####################################################################################################
|
|
#
|
|
# More information: https://macmule.com/2014/12/07/how-to-change-the-automatic-proxy-configuration-url-in-system-preferences-via-a-script/
|
|
#
|
|
# GitRepo: https://github.com/macmule/setAutomaticProxyConfigurationURL
|
|
#
|
|
# License: http://macmule.com/license/
|
|
#
|
|
####################################################################################################
|
|
|
|
# HARDCODED VALUES ARE SET HERE
|
|
autoProxyURL=""
|
|
|
|
# CHECK TO SEE IF A VALUE WAS PASSED FOR $4, AND IF SO, ASSIGN IT
|
|
if [ "$4" != "" ] && [ "$autoProxyURL" == "" ]; then
|
|
autoProxyURL=" "
|
|
fi
|
|
|
|
# Detects all network hardware & creates services for all installed network hardware
|
|
/usr/sbin/networksetup -detectnewhardware
|
|
|
|
IFS=$'\n'
|
|
|
|
#Loops through the list of network services
|
|
for i in $(networksetup -listallnetworkservices | tail +2 );
|
|
do
|
|
|
|
# Get a list of all services
|
|
autoProxyURLLocal=`/usr/sbin/networksetup -getautoproxyurl "$i" | head -1 | cut -c 6-`
|
|
|
|
# Echo's the name of any matching services & the autoproxyURL's set
|
|
echo "$i Proxy set to $autoProxyURLLocal"
|
|
|
|
# If the value returned of $autoProxyURLLocal does not match the value of $autoProxyURL for the interface $i, change it.
|
|
if [[ $autoProxyURLLocal != $autoProxyURL ]]; then
|
|
/usr/sbin/networksetup -setautoproxyurl $i $autoProxyURL
|
|
echo "Set auto proxy for $i to $autoProxyURL"
|
|
fi
|
|
|
|
# Enable auto proxy once set
|
|
/usr/sbin/networksetup -setautoproxystate "$i" off
|
|
echo "Turned off auto proxy for $i"
|
|
|
|
# Enable auto proxy discovery once set
|
|
/usr/sbin/networksetup -setproxyautodiscovery "$i" off
|
|
echo "Turned off auto proxy discovery for $i"
|
|
|
|
done
|
|
|
|
unset IFS
|
|
|
|
# Echo that we're done
|
|
echo "Auto proxy disabled for all interfaces"
|