Skip to main content
Solved

Pushing Proxy PAC files via JSS - Verifying settings

  • February 3, 2017
  • 5 replies
  • 54 views

Forum|alt.badge.img+2

Hi all, what is the most efficient way to push proxy.pac settings via JSS? And how can we verify which settings are in use?
We are using Sierra 10.12.3 and Jamf Pro 9.97
Thanks a lot!

Best answer by perrycj

@mteget65 .pac files are usually as apart of a URL and you can point a mac or macs to this URL to utilize the .pac file.

If you're doing it this way, you can just set the proxy pac URL in system preferences (network > advanced > proxies) via script. Here is something you can use:

#!/bin/bash

# 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=$4
echo "[$(date)] Proxy URL is $autoProxyURL" >>"$LOGFILE"
fi

# Detects all network hardware & creates services for all installed network hardware
/usr/sbin/networksetup -detectnewhardware

IFS=$'
'

    #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
            networksetup -setautoproxyurl $i $autoProxyURL
            echo "Set proxy for $i to $autoProxyURL"
        fi
    done

echo "Proxies All Present And Correct..."

unset IFS

You can run this from Self Service or as apart of your first run script/workflow. You can also set the .pac file URL as the $4 variable in the JSS or just hard-code it into this script. Up to you but I would just use the variable instead of hard-coding. Hopefully it helps you out.

5 replies

Forum|alt.badge.img+14
  • Valued Contributor
  • Answer
  • February 3, 2017

@mteget65 .pac files are usually as apart of a URL and you can point a mac or macs to this URL to utilize the .pac file.

If you're doing it this way, you can just set the proxy pac URL in system preferences (network > advanced > proxies) via script. Here is something you can use:

#!/bin/bash

# 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=$4
echo "[$(date)] Proxy URL is $autoProxyURL" >>"$LOGFILE"
fi

# Detects all network hardware & creates services for all installed network hardware
/usr/sbin/networksetup -detectnewhardware

IFS=$'
'

    #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
            networksetup -setautoproxyurl $i $autoProxyURL
            echo "Set proxy for $i to $autoProxyURL"
        fi
    done

echo "Proxies All Present And Correct..."

unset IFS

You can run this from Self Service or as apart of your first run script/workflow. You can also set the .pac file URL as the $4 variable in the JSS or just hard-code it into this script. Up to you but I would just use the variable instead of hard-coding. Hopefully it helps you out.


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • February 3, 2017

@perrycj that looks oddly familiar

Good to know it still works.

You can also use a profile for this now


Forum|alt.badge.img+14
  • Valued Contributor
  • February 3, 2017

@bentoms Yea? ha. It was here when I started but yea, it still works.


Forum|alt.badge.img+2
  • Author
  • New Contributor
  • February 8, 2017

Thanks perrycj ! Works absolutely fine! ;-)


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • February 8, 2017

I do it via a single entry in Files & Processes > execute command:

networksetup -listallnetworkservices | grep -v "*" | while read a; do networksetup -setautoproxyurl "$a" http://proxy.company.net/accelerated_pac_base.pac ; networksetup -setproxyautodiscovery "$a" on ; done

I have to set autoconfigure and autodiscovery since Sierra gets cranky if both aren't set even though we're actually only using autoconfigure.