Lion - Setting Airport at first boot after imaging

ewettach
New Contributor III

How can I get Lion to set the Airport SSID and password in the imaging workflow? I have used the command...
/usr/sbin/networksetup -addpreferredwirelessnetworkatindex en0 "SSID" 0 wpa2 "password"

This works great on the Macbook Air I am imaging, but I can't seem to get it in the imaging workflow. I always have to manually run this script after it reboots from being imaged.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Did you set the script to run "At Reboot" in Casper Admin? it sounds like it needs to run on the Mac as a first run script after it reboots, not while in its imaging state, which would make perfect sense if that's the case.

And, Lion configuration profiles can only be set via scope, not inside an imaging workflow. They are basically MCX settings in a pretty GUI, so apply them the same way you would any MCX setting, via Smart Groups, etc.

View solution in original post

19 REPLIES 19

bentoms
Release Candidate Programs Tester

I guess other macs where it's not taking are not airs?

MacBook Airs have wireless as en0 others en1 (I think).

You'll either need to script finding the wireless device or could you use configuration profiles?

ewettach
New Contributor III

en0 is the wireless for Macbook Airs. Like I mentioned, it works just fine when scripting after the computer has come back up after the initial image. I just want this to be an automated process. A configuration profile would work as well. How can I put the configuration profile as part of the imaging process?

Thanks so much

mm2270
Legendary Contributor III

Did you set the script to run "At Reboot" in Casper Admin? it sounds like it needs to run on the Mac as a first run script after it reboots, not while in its imaging state, which would make perfect sense if that's the case.

And, Lion configuration profiles can only be set via scope, not inside an imaging workflow. They are basically MCX settings in a pretty GUI, so apply them the same way you would any MCX setting, via Smart Groups, etc.

rtrouton
Release Candidate Programs Tester

You can set up a LaunchDaemon script combo to do this, if you want this applied as part of the imaging process.

I have an example of how to use this with network settings posted here:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/network_setup

This script doesn't set wireless settings, but it does show how you can set up the launchdaemon and script.

bentoms
Release Candidate Programs Tester

Re: config profiles.

You'll need Casper 8, a valid APNS certificate & a cert on the JSS. (I think this is right).

Once that's all inplace, Imaged 10.7 macs can then have profiles assigned to them like scoping any other policy.

jhbush
Valued Contributor II

You could also just setup a standalone profile created in iPCU and install it via the Profiles command. I use this for our Radius network. I add the certificates that I need as well. If you want to use it as a login window profile you'll need to add that in the xml file of the profile.

ewettach
New Contributor III

I had the script set to "After" instead of "At reboot". This resolved the issue. Thanks

cbrewer
Valued Contributor II

/usr/sbin/networksetup -listallhardwareports | grep -A 1 Wi-Fi | grep Device | awk '{print $2}'

This will determine whether wireless is on en0 or en1.

CasperSally
Valued Contributor II

I use the setairportnetwork.sh from the resource kit ran at reboot. Works in Lion for airs and macbooks in my testing.

techmchs
New Contributor III

setairportnetwork.sh in the resource kit is not working for us.. apperently apple changed airport to en1.. I changed that in the script and it works in terminal but not when script is applied at reboot. I'll paste below.. should this work? or can someone point me to a script that will?

Thanks!

# HARDCODED VALUES SET HERE
SSID="" #The SSID of the wireless network to connect to
password="" #This only needs to be set if a password is required

# CHECK TO SEE IF A VALUE WERE PASSED IN FOR PARAMETERS $4 THROUGH $5 AND, IF SO, ASSIGN THEM
if [ "$4" != "" ] && [ "$SSID" == "" ]; then SSID=$4
fi

if [ "$5" != "" ] && [ "$password" == "" ]; then password=$5
fi

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

if [ "$SSID" == "" ]; then echo "Error: The parameter 'SSID' is blank. Please specify a SSID." exit 1
fi

OS=/usr/bin/sw_vers -productVersion | /usr/bin/colrm 5

if [[ "$OS" < "10.6" ]]; then echo "Setting airport SSID to $SSID..." /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z -A["$SSID"] --password="$password"
else echo "Setting airport SSID to $SSID..." /usr/sbin/networksetup -setairportnetwork en1 "$SSID" "$password"

CasperSally
Valued Contributor II

If that's your wireless pw you might want to remove it.

techmchs
New Contributor III

Thanks.. I got that right away...

Any insight to the my question?:)

techmchs
New Contributor III

delete double post

bentoms
Release Candidate Programs Tester

No insight. But this is something I think your better setting via a configuration profile.

rtrouton
Release Candidate Programs Tester

Here's a script that may help:

# Determines which OS the script is running on
OS=`/usr/bin/sw_vers | grep ProductVersion | cut -c 17-20`

# On 10.7, the Wi-Fi interface needs to be identified
wifiDevice=`/usr/sbin/networksetup -listallhardwareports | awk '/^Hardware Port: Wi-Fi/,/^Ethernet Address/' | head -2 | tail -1 | cut -c 9-`

# Once the running OS is determined, the settings for the wireless
# network are created and set as the first preferred network listed

if [ "${OS}" = "10.7" ]; then
    sudo networksetup -addpreferredwirelessnetworkatindex $wifiDevice settings go here
else
    sudo networksetup -addpreferredwirelessnetworkatindex AirPort settings go here
fi

techmchs
New Contributor III

Thanks to both of you... heading in the direction of configuration profile.. how often does that check it for a change? Can I force it to run?

techmchs
New Contributor III

Configuration profile worked.. need more info..opened support case..thanks.

Eyoung
Contributor

New to using profiles... under Lion at any rate.

What's the workflow to get the profile on the machine then loaded at image time?

I was thinking putting the .mobileconfig file someplace (anyplace under admin?) then running a script to trigger the install command, I assume set to after will do.

this the right basic methodology?

thanks.

techmchs
New Contributor III

What we are going to do is use a unique identifier in the computer name, in our case, (username_fac_laptop) or (username_stu_laptop) to create a smart group of newly imaged computers. You can have profile manager pointing at the smart group before the clients are actually in the group.. once the clients are added to the group at image time they should get the info immediately from profile manager..

we tested one and it worked.. so thats the way we are headed..

Hope that makes sense.. im really tired.. email me if you need more details.