Use Casper to change networking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 09:11 AM
I'm trying to do all my post imaging configuration with scripts. One script
changes the network location and sets up some proxies. Trouble is that after
the script runs the ssh session terminates. The location change sends a new
dhcp request or something and the computer is off line for half a second.
That messes with Casper's ablity to execute the rest of the policy.
Lesson learned. Don't change network connections over a remote session.
Seems so obvious now.
The nice thing about the script was that it would create locations and
proxies on the default service names - Ethernet 1 for MacPros and Ethernet
for MacBooks.
I'm wondering if I can still use the script and Casper but somehow make the
script run off the remote session. Maybe use launchd?
Any tricks to changing the network on a remote computer with Casper?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 09:54 AM
Do the settings need to change? If not, you can easily script this via post image and set it once and be done with it.
-Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 01:38 PM
Hi Tom, I moved them out of a policy and added them to the configuration as
"after reboot" scripts. That fixed works. Here's the script.
#!/bin/sh
####################################################################################################
# setupNetworkLocations.sh
#
#
# Created by John McAdams on 9/30/11.
# Copyright 2011 Tekserve. All rights reserved.
####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# setupNetworkLocation.sh -- Create the two network locations.
#
# SYNOPSIS
# sudo setupNetworkLocation.sh
# sudo setupNetworkLocation.sh <mountPoint> <computerName> <currentUsername>
<timeServer>
#
# DESCRIPTION
# This script will use networksetup to create two locations, "Proxy"
# & "No Proxy" and set the http & https proxies.
#
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
# HARDCODED VALUES ARE SET HERE
location=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO
"location"
if [ "$4" != "" ] && [ "$location" == "" ];then
location=$4
fi
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
# Change $IFS environment variable to allow a "for" statement to capture an
entire line.
defaultIFS=$IFS
IFS='
'
networkLocations=$(/usr/sbin/networksetup -listlocations)
myLocations=( 'Proxy' 'No Proxy' )
for (( i = 0; i < ${#tiffanyLocations[@]} ; i++ ))
do
newLocation="${myLocations[$i]}"
/usr/sbin/networksetup -createlocation "$newLocation" populate
/usr/sbin/networksetup -switchtolocation "$newLocation"
if [ "$newLocation" == "Proxy" ]; then
for service in $(networksetup -listallnetworkservices | sed -e '1d')
do
if [ "$service" != "FireWire" ]; then
/usr/sbin/networksetup -setwebproxy "$service" proxy.1.net 8080
/usr/sbin/networksetup -setsecurewebproxy "$service" proxy.1.net
8080
fi
done
fi
done
IFS=$defaultIFS
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 01:51 PM
John,
Just a quick note.
If you were to use a PAC file to give your clients proxy info & that PAC file was hosted internally. You'd not need separate locations.
As the Macs when on the LAN would use the proxies as specified in the PAC file, when off the LAN they'd not see the PAC file... So will not use the proxy...
Works for me!!
Regards,
Ben.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 02:05 PM
Thanks Ben. I'll look into that. I've never used PAC files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-06-2011 02:14 PM
Me neither before starting latest job!
Ask your nw admin if they use WPAD, if so.. all you need tick is Automatically Detect.
Regards,
Ben.
