Setting web proxy to Auto Discovery

achmelvic
New Contributor III

Our college web proxy needs to have auto discovery set in network settings for it to be found on our network.

Unless I missing it is there an built in means to do this using Casper with either policies or Configuration Profiles?

Or is there a existing script kicking about which will set this? I've found the one for specifying a proxy server address but like I say ours is done through auto discovery using DNS records.

I've got it setting it ok using the terminal command:

sudo networksetup -setproxyautodiscovery Ethernet on

Now I've just trying to get this working as a script in Casper. I may be trying to run before I can walk as my bash skills are pretty basic but I'm trying to write this so it can use parameter variables for different network interfaces and both enable and disable the setting. Here's what I've got by cheekily editing the existing setWebProxy script:

#!/bin/sh
# HARDCODED VALUES ARE SET HERE
networkInterface=""
AutoProxyDiscovery=""


# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "networkInterface"
if [ "$4" != "" ] && [ "$networkInterface" == "" ];then
    networkInterface=$4
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 5 AND, IF SO, ASSIGN TO "AutoProxyDiscovery"
if [ "$5" != "" ] && [ "$AutoProxyDiscovery" == "" ];then
    AutoProxyDiscovery=$5
fi


####################################################################################################
# 
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################

if [ "$networkInterface" == "" ]; then
    echo "Error:  No network interface has been specified."
    exit 1
fi

if [ "$AutoProxyDiscovery" == "" ]; then
    echo "Error:  No setting been specified."
    exit 1
fi

    echo "Setting web proxy for OS $OS..."
    /usr/sbin/networksetup -setproxyautodiscovery "$networkInterface" "$AutoProxyDiscovery"

However when I import this into casper and set parameter 4 to Ethernet and parameter 5 to on and trigger the script I get:

Running script setAutoProxyDiscovery.sh...
Script exit code: 4
Script result: Setting web proxy for OS ...
**Error: The parameters were not valid.

Error running script: return code was 4.

As I say my bash skills are still developing so I apologize for any obvious error here!!

3 REPLIES 3

Johnny_Kim
Contributor II

Try the Parameter 4 with "Built-in Ethernet" and see if that works.

achmelvic
New Contributor III

Thanks Johnny, just the pointer I needed!

Turns out the problem was my own stupidity...whilst the script will be used mostly on iMacs, where the interface is Ethernet, I've been testing it on a my MBP which has an external thunderbolt adaptor so the interface is 'Thunderbolt Ethernet', simply changed parameter 4 to that and it works straight away! :-)

I guess next I'll have to look at renaming the interfaces on our MBPs so it's named as Ethernet across the board or change the policy scope.

Johnny_Kim
Contributor II

You're welcome! Glad you figured it out.