AutoDMG and WiFi Configuration

sapalmerBCS
New Contributor III

I'm also working with support on this issue, but I thought I would try out the community as well...

We just did our Jump Start training in early December. When the trainer was here we created a Base Image using the 10.11.1 installer and AutoDMG. The configuration called "Base System" only has 4 things. It has the clean AutoDMG created system DMG and 3 scripts. One script joins the WiFi, one sets the timeserver, and the last sets the timezone. It is also setup to create a Management Account (hidden) called Casper. All of this works perfectly with the 10.11.1 system.

After the JumpStart training (I think literally the day after he left) 10.11.2 came out. I thought I would go ahead and update the Base Image before I went any further. I downloaded the new "Install OS X El Capitan.app" from the App store, updated AutoDMG and created a new DMG for 10.11.2. I updated the Base System configuration to use this new image instead of the old one.

When I use this updated configuration to image a test system (MacBook Air) (via Casper Image and Target Mode imaging) the system gets laid down just fine, but the wifi script doesn't work and it never connects to wireless. It also doesn't create the hidden Casper user. I've recreated the DMG 3-4 times. If I plug it into the network via thunderbolt network adapter before the first reboot after imaging it will connect and associate with Casper, but the wifi script still never joins it to the wireless. I do know that the script is actually running at some point because I added a line to the bottom of it for testing to "touch /users/Here.IAm" and the file gets created on the test system.

Support has been very responsive and we have gone back and forth but haven't found a solution. I'm wondering if I'm missing a step that everyone else using AutoDMG to create a never booted image uses to get a MacBook Air connected to WiFi on first boot uses. I did see someone suggest adding a configuration profile for the wireless into the AutoDMG image with a utility that makes a pkg for the configuration profile. I haven't tried that yet.

Thanks for any suggestions,
Scott

1 ACCEPTED SOLUTION

sapalmerBCS
New Contributor III

So...I was looking through logs from both a successful 10.11.1 and a 10.11.2 and something just made me think that it was still a timing issue. Before I saw your post about the Network tab I thought, let me try bumping the sleep time up a few seconds so I changed it to "sleep 15".

I've since tried it 3 times in a row (to make sure it wasn't a fluke) and it worked all 3 times on this test machine.

I guess the script was trying to run before the services were started. I'm sure there is a better way to do this, like checking for the service and waiting, but a 15 second sleep isn't going to kill my workflow.

I'm going to consider this working until I see otherwise!

View solution in original post

18 REPLIES 18

sam_clark
New Contributor III

Hey Scott,

Is it possible to post a secure portion of the script to see if there is something that can be modified to ensure the wifi interface is being detected? You could also try putting a verbose output log into the script to see if that can point you to the reason why your script isn't enabling Wifi on the targeted device.

This should create a script log after it runs:

#!/bin/sh -vx 

exec > /path/to/mylog.log 2>&1

To my knowledge AutoDMG wouldn't really have anything to do with the Wifi being enabled or not. I suspect it's a script/OS problem.

Hope this helps.

sapalmerBCS
New Contributor III

Thanks for your quick response. Below is a copy of the script I'm using with the password changed. I left special characters in this replacement password with escapes because my real password contains a special character.

I do think it's important to note that after the image runs if I login and run the exact same script manually it works just fine.

I'm going to try adding the verbose logging at your suggestion and I'll be back with the results.

Something I also forgot to mention that is odd. After imaging with Casper Imaging and rebooting (a couple times for testing) and having it never join the WiFi I booted to the Recovery partition and it connected to the WiFi configured in the script. That confused me quite a bit.

#!/bin/sh

# Determines which network interface is the the Wi-Fi radio. 
wifi_device=$(/usr/sbin/networksetup -listallhardwareports | awk '/^Hardware Port: (Wi-Fi|AirPort)/,/^Ethernet Address/' | head -2 | tail -1 | cut -c 9-)

# Feedback for the log file.
echo "Setting airport SSID to myssid."

# Sets the Wi-Fi network to the defined network name and password.
/usr/sbin/networksetup -setairportnetwork "$wifi_device" "myssid" "$omeP@$sword"

scottb
Honored Contributor

So what happens if you just run that script on the newly-imaged Mac - does it work?
You're sure that you made no other changes to the Configuration other than choosing the new AutoDMG?

bpavlov
Honored Contributor

How exactly are you running these scripts? Are they part of Casper Imaging? Or are you running it in a package that you add AutoDMG to create a custom base OS?

Also what happens if you run that script manually on a 10.11.2 computer? In terminal, do:
sh -x /path/to/script.sh

sapalmerBCS
New Contributor III

Yes, if I run the script on any 10.11.2 Mac that I can get logged into it works.

I added the scripts through Casper and they are part of the configuration and seen in Casper Imaging. I didn't add anything or make any changes to the DMG produced by AutoDMG.

I made the changes to the script to get a verbose output. I imaged a test machine, but here is the problem; the hidden user Casper that is configured to be created by Casper Imaging as part of the configuration isn't created. So I have no way to login to the machine after it images and reboots. This user is created just fine if the only change I make to the configuration is to uncheck Base10.11.2.dmg and check Base10.11.1.dmg in the configuration. Everything else stays the same.

I suspect since the Casper hidden, admin user is never created it can't run the wireless (or any other script) successfully. Is this plausible? As I mentioned earlier if when rebooting after the imaging process I connect a thunderbolt network adapter it will create the Casper user, talk to the JSS and do further configuration, but it never connects to WiFi. It will only do this if I connect the wired network before the first boot. If I tried to reboot after that and connect it to a wired connection it doesn't work.

bpavlov
Honored Contributor

You need to check the log. Target Disk Mode that machine to your computer and look at the logs. Don't plug in the Thunderbolt Ethernet adapter. You obviously want to see why exactly that command is failing.

sapalmerBCS
New Contributor III

I just connected to a newly imaged machine with Target Mode to check the log and the output of the networksetup command was "All Wi-Fi network services are disabled".

Do I need to start something or check for something running in the script? Should i put a short delay in the beginning of the script to make sure it waits for a service to start?

scottb
Honored Contributor

Ahh - I saw a thread the other day where someone found 10.11.2 was doing that.
Let me search...

OK, my memory was off, but this is similar to what you're seeing...what version of JSS are you running?

Wifi disabled...

sapalmerBCS
New Contributor III

JSS is 9.8.1

Tried adding "sleep 5" in the script to delay it running...no change.

sam_clark
New Contributor III

Scott,

Do you have this script priority in the JSS or Casper Imaging set to run "At Reboot" by chance?

sapalmerBCS
New Contributor III

Yes, all 3 scripts (including wireless configuration) are set to run "At Reboot".

sam_clark
New Contributor III

In Casper Imaging under the Network tab can we ensure that the Connection Type is set to Airport and try again? If you're not seeing these options, click "Show Custom" in the upper left corner of the Casper Imaging pane.

sapalmerBCS
New Contributor III

So...I was looking through logs from both a successful 10.11.1 and a 10.11.2 and something just made me think that it was still a timing issue. Before I saw your post about the Network tab I thought, let me try bumping the sleep time up a few seconds so I changed it to "sleep 15".

I've since tried it 3 times in a row (to make sure it wasn't a fluke) and it worked all 3 times on this test machine.

I guess the script was trying to run before the services were started. I'm sure there is a better way to do this, like checking for the service and waiting, but a 15 second sleep isn't going to kill my workflow.

I'm going to consider this working until I see otherwise!

sam_clark
New Contributor III

That's awesome Scott, glad you got it working!

sapalmerBCS
New Contributor III

Thanks for everyone's help. I wouldn't have tracked it down without the assistance.

roiegat
Contributor III

I know with our Active Directory binding we have to make sure we run the script to set the network time and run the sync because if there is a time offset of more then 4 minutes between the computer and the Active Directory server then the binding fails.

eagleone
New Contributor

@sapalmerBCS What does the script look like with the sleep command in it?

sapalmerBCS
New Contributor III
#!/bin/sh -vx 

exec > /Users/WirelessSetup.log 2>&1

#Wait 25 seconds
sleep 25

# Determines which network interface is the the Wi-Fi radio. 
wifi_device=$(/usr/sbin/networksetup -listallhardwareports | awk '/^Hardware Port: (Wi-Fi|AirPort)/,/^Ethernet Address/' | head -2 | tail -1 | cut -c 9-)

# Feedback for the log file.
echo "Setting airport SSID to ssid."

# Sets the Wi-Fi network to the defined network name and password.
/usr/sbin/networksetup -setairportnetwork "$wifi_device" "ssid" "password"