Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: set ‘Auto Proxy Discovery’ from command line? #382594
    cdaley
    Participant

    Hi Brad. Sure.

    I have it as a Launchdaemon that runs once at startup. Here is the script….

     

    #!/bin/bash

    # Mac OS X Build Environment
    # Date: 06/2012
    # Author: Chris Daley

    # This script will configure the Auto Proxy Discovery, it applies to only 10.6.x machines.
    # Unlike 10.7.x there is no flag for the command line networksetup to configure this. For
    # 10.7 this is known as -setproxyautodiscovery

    # The script generates the “ProxyAutoDiscoveryEnable” for each network service and configures it to 1
    # In other words makes it active.

    #—————————————————————————————————–

    # Export Paths
    # This is so we can use PlistBuddy

    export PATH=${PATH}:/Volumes/Macintosh\ HD/usr/libexec

    #—————————————————————————————————–

    _PREFERENCE=”/Library/Preferences/SystemConfiguration/preferences.plist”

    #—————————————————————————————————–

    # Backup existing preference file

    cp “${_PREFERENCE}” “${_PREFERENCE}”.old

    #—————————————————————————————————–

    # This will obtain the unique UUIDs for each of the network services, this is unique to each machine as well, hence
    # why it has to be determined before we can continue.

    for i in $(cat /Library/Preferences/SystemConfiguration/preferences.plist | grep /NetworkServices/ | cut -c 32-67);
    do

    # For each of the UUIDs, if it’s an Ethernet or Airport network service, then configure the Auto Proxy Discovery.

    for x in $(PlistBuddy -c ‘Print :’NetworkServices:$i:UserDefinedName $_PREFERENCE)
    do

    case “${x}” in
    Ethernet )

    _CHECK=`PlistBuddy -c ‘Print :’NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable $_PREFERENCE 2>/dev/null | wc -l`

    # If $_CHECK is 1 then we know the key “ProxyAutoDiscoveryEnable” exists. Lets just have a command that
    # ensures it is the value of 1 anyway

    if [ “${_CHECK}” -gt 0 ]; then

    PlistBuddy -c “Set :NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable 1” “${_PREFERENCE}”

    # If $_CHECK is 0 then we know the key “ProxyAutoDiscoveryEnable” does not exists. This would indicate that
    # the proxy is not configured. So lets create the key and configure it to 1

    else

    PlistBuddy -c “Add :NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable integer 1” “${_PREFERENCE}”

    fi

    ;;

    AirPort )

    _CHECK=`PlistBuddy -c ‘Print :’NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable $_PREFERENCE 2>/dev/null | wc -l`

    # If $_CHECK is 1 then we know the key “ProxyAutoDiscoveryEnable” exists. Lets just have a command that
    # ensures it is the value of 1 anyway

    if [ “${_CHECK}” -gt 0 ]; then

    PlistBuddy -c “Set :NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable 1” “${_PREFERENCE}”

    # If $_CHECK is 0 then we know the key “ProxyAutoDiscoveryEnable” does not exists. This would indicate that
    # the proxy is not configured. So lets create the key and configure it to 1

    else

    PlistBuddy -c “Add :NetworkServices:$i:Proxies:ProxyAutoDiscoveryEnable integer 1” “${_PREFERENCE}”

    fi

    ;;

    * )

    # Do nothing

    echo ” ”

    ;;
    esac

    done

    done

    #—————————————————————————————————–

    # Cleanup

    rm -rf /Library/Scripts/configure_auto_proxy_discovery_snow.sh
    rm -rf /Library/LaunchDaemons/###.#####.auto_discovery_proxy.plist

    #—————————————————————————————————–

    exit 0

    in reply to: set ‘Auto Proxy Discovery’ from command line? #382574
    cdaley
    Participant

    Hi Guys.

    I’ve had a lot of troubles to get this applescript/application to launch automatically for me, whether it be a login, logout or launch agent. It simply just doesn’t work, and I don’t think it’s really meant to anyway. Even embedding the applescript into a bash script, gave me applescript errors. As a stand alone application it does work – which is not feasible if you need to configure this for a lot of machines.

    So I went back to the drawing board, and worked out that there is a key in /Library/Preferences/SystemConfiguration/preferences.plist called “ProxyAutoDiscoveryEnable” for each of the network services, that is present when the auto discovery proxy is active.

    In order to script this, you have to work out the unique UUID for each network service, which is something like…

    630A061A-7256-4631-9114-BECC6775B371

    These values exist in the plist, you just have to “obtain” them and place them in an array for instance.

    These values are unique for each network service and unique for each machine, hence why is has to be obtained, if you want to automate this and roll it out to a bunch of machines.

    Using this unique UUID, then drill down into the plist file and add the “ProxyAutoDiscoveryEnable” key with a value of 1.

    Straight away the Auto Proxy Discovery is active.

    This script relies on the PlistBuddy command, to read (print), add and set the /Library/Preferences/SystemConfiguration/preferences.plist.

    I understand the previous requests for this are over a year old. Yet some of us in the world are still having to manage and deploy Snow Leopard machines.

    So if anyone would like to try out my script, please let me know.

    Cheers Chris.

    in reply to: set ‘Auto Proxy Discovery’ from command line? #382519
    cdaley
    Participant

    Hi Guys.

    I also have been looking for a solution to this. Unlike Mac OS X Lion, there is no command line that can configure this. In lion there is a setproxyautodiscovery flag as part of the networksetup command, this flag does not exist in 10.6.

    I have developed an applescript that configures this. I intend to launch it an as app when the local admin logs in after a machine has been re-imaged. It configures the auto proxy discovery for both ethernet and airport.

    It’s only a draft. It doesn’t open the system preferences padlock if it’s locked, this is possible, search google. Something like this could be used…

    tell application “System Events”

    tell application process “System Preferences”

    tell window “Network”

    if exists button “Click the lock to prevent further changes.” then

    click (button “Click the lock to prevent further changes.”)

    end if

    end tell

    end tell

    end tell

    If it runs twice, it will actually untick the auto proxy discovery, so it still needs some work, but it a start for those that are also having this issue.

    Cheers Chris.

    tell application “System Preferences”

    activate

    set the current pane to pane id “com.apple.preference.network”

    get the name of every anchor of pane id “com.apple.preference.network”

    reveal anchor “Advanced Ethernet” of pane id “com.apple.preference.network”

    tell application “System Events” to tell process “System Preferences”

    click (radio button “Proxies” of tab group 1 of sheet 1 of window “Network”)

    click checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 of window “Network”

    click (button “OK” of sheet 1 of window “Network”)

    click (button “Apply” of window “Network”)

    end tell

    activate

    set the current pane to pane id “com.apple.preference.network”

    get the name of every anchor of pane id “com.apple.preference.network”

    reveal anchor “Advanced Airport” of pane id “com.apple.preference.network”

    tell application “System Events” to tell process “System Preferences”

    click (radio button “Proxies” of tab group 1 of sheet 1 of window “Network”)

    click checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 of window “Network”

    click (button “OK” of sheet 1 of window “Network”)

    click (button “Apply” of window “Network”)

    end tell

    end tell

    • This reply was modified 12 years, 9 months ago by cdaley.
    • This reply was modified 12 years, 9 months ago by cdaley. Reason: Incorrect Info
Viewing 3 posts - 1 through 3 (of 3 total)