The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Networking (http://hintsforums.macworld.com/forumdisplay.php?f=14)
-   -   network setup script (http://hintsforums.macworld.com/showthread.php?t=81235)

patgmac 11-16-2007 05:11 PM

Quote:

Originally Posted by tlarkin (Post 424640)
so, we have deployed over 5,500 macbooks as mobile users at my work. For some reason some of the client macs are not keeping the proper airport network settings. So I am trying to write a log in hook that will force the clients to join our secured wifi network when they log in on our network.

The script runs but errors out when I test it, saying that the airport is turned off so it can not run.

I use a launch daemon named edu.myschool.airportfix.plist placed in /Library/LaunchDaemons/ which contains:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/Propert
yList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>GroupName</key>
        <string>wheel</string>
        <key>Label</key>
        <string>edu.myschool.airportFix.plist</string>
        <key>OnDemand</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
                <string>/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport
</string>
                <string>-a</string>
        </array>
        <key>WatchPaths</key>
        <array>
                <string>/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist</strin
g>
                <string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.p
list</string>
        </array>
</dict>
</plist>

This watches for power events such as when you bootup or wake the machine and it will trigger the machine to join a preferred network. I put it in a pkg and deployed it with an ARD task server with a postinstall script:

Code:

#!/bin/sh

## Postflight script for AirportFix ##

launchctl load /Library/LaunchDaemons/edu.emory.airportFix.plist


tlarkin 11-16-2007 05:16 PM

Pat,

thanks for the input! I haven't really messed with launch daemons that much but I will definitely look at your solution. So, once you create the daemon and edit the plists you are good to go?

Thanks again for your help I appreciate it.

patgmac 11-16-2007 05:29 PM

Quote:

Originally Posted by tlarkin (Post 425850)
Pat,

thanks for the input! I haven't really messed with launch daemons that much but I will definitely look at your solution. So, once you create the daemon and edit the plists you are good to go?

Thanks again for your help I appreciate it.

You're creating the plist, not editing. You can use Textedit set to plain text, paste the contents above, modify the line edu.myschool.airportfix.plist to match what you're going to name the file and save it with that name to /Library/LaunchDaemons/.

tlarkin 11-17-2007 06:07 PM

ok quick question before I try this on monday. How will it effect other wifi networks? The users take their laptops home every day and on the weekends, so they need to connect to other wifi networks.

patgmac 11-17-2007 06:11 PM

It won't hurt it. This will just make Airport go through it's preferred network list or recent networks.

tlarkin 11-17-2007 06:24 PM

thanks one more noob question, where do I put in the SSID and encryption passkey at in the plist?

tlarkin 11-20-2007 11:30 AM

OK, so I am looking at the framework where it keeps the data which is under:

/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport

So, if I create a this launchd item it will pull the info from that framework? So, I should set up the wireless on a machine and make sure it works and then create the .plist. I am just not connecting all the dots I don't think

EDIT....

Okay, I think I see what you did there I hastily read over the plist file. You also edited a plist under /Library/Preferences/systemconfiguration

Okay I think I grasp what is going on now and see a solution. So, are you pushing out both that launchd item and the plist over the network? Because a certain percentage of our user base just drops the WiFi encryption key all the time. I even have repeat offenders, it seems like some OS X installs just don't want to listen.

Okay, so I can edit the plist file under /Library/preferences/systemconfigurations/com.apple.airport.plist and be done with it. I just got to figure out a way so that every time a user logs in that launchd item and the plist gets pushed out to the users. Or I guess I would just have to really do it once, and the launchd item would then make it happen at log in.

tlarkin 11-26-2007 08:59 AM

Well, I just this morning got an email from my Apple SE, and he says my script works fine on his non managed machines running 10.4.10, 10.4.11, and 10.5.1

However, it doesn't work on my machine, if anyone else has the time could they fill in the blanks on the script and run it on their machine and see if it works. You could test it by completely removing the preferred WiFi network on your system, fill in the blanks, then run the script. It should add that SSID and security settings back to your system.

We do have an application monitor running which I am wondering if it is causing the script not to run properly.

Thanks,

tlarkin 11-27-2007 12:47 PM

quick question, putting the plist file in /Library/LaunchDaemons will automatically run it at boot up or log in?

patgmac 11-27-2007 01:00 PM

Quote:

Originally Posted by tlarkin (Post 429035)
quick question, putting the plist file in /Library/LaunchDaemons will automatically run it at boot up or log in?

Sort of. It's not the location that makes it run, it's the contents of the plist that specifies when it's going to run. The "launchd" process, which is always running, is supposed to know what to do and when to do it based on the files in /Library/LaunchDaemons, /Library/LaunchAgents and equivalent folders in /System/Library/.

See http://www.afp548.com/article.php?st...50620071558293

tlarkin 11-27-2007 01:30 PM

Thanks, I tossed the plist on a few guinea pig users and told them to check back with me if the wireless still keeps failing.

In the next few weeks we start assessment tests and they want to do it over wireless, and well I have a fairly large percentage of students having wireless issues. I also need to push out the 10.4.11 update to a few users because that is suppose to resolve some wireless bugs.

I hope Apple really gets a fix on this soon, because I have a lot of panicking educators asking me all these what ifs....

As a back up plan I got tons of mini switches and patch cables so if push comes to shove...

tlarkin 11-29-2007 05:58 PM

update
 
Today, I made a policy which puts the plist that I pretty much copied from this thread and changed the name according to plist standards and our domain and school, out to every client's /Library/LaunchDaemons directory. The policy is set to run once on each computer, and it checks each client every 15 minutes. Before I left work today over 500 had gotten the plist and tomorrow all 5000 clients should have it, or at least most.

AFAIK, it was working. The test machines I put it on did not seem to loose their preferred network connections when restarted, logged in/out, or put to sleep.

So, thanks a lot for the help.

lucidsystems 01-08-2008 09:40 PM

Auto Setup of Airport
 
Quote:

Originally Posted by tlarkin (Post 425769)
The script is broken, and I am not sure what I am doing wrong.

Under Mac OS 10.5.1 the networksetup command is able to configure the AirPort. However, you must not enable or disable the power within the script unless you include a long time out.

When you connect to a wireless network using the AirPort menu item, the wireless access point password is stored in both the user and the System Keychains. However, using the networksetup command the wireless access point password is not stored within the System or User Keychains. Dose anyone know of a command which will do the same thing as connecting via the GUI?

We are able to add the password to to an unlocked keychain with the help of the security command. However, our current stumbling block is adding the password to the locked /Library/Keycahins/System.keychain via the command line, without resetting the system Keychain to a known password.

How are others automatically configuring the KeyChain and AirPort, with out cloning the machine?

Thank you all the best.
The Lucid Team.


--
Lucid Information Systems
http://www.lucidsystems.org

tlarkin 01-09-2008 09:53 AM

lucid,

Thanks, but all my clients are tiger clients at the moment.

elcode 02-19-2008 10:42 AM

scripting airport on Mac OS 10.5
 
Lucid,
We are facing exactly the same problem as you described below. Did you find any solution to how automatically configure airport on Mac OS 10.5?

Any help would be greatly appreciated.

Quote:

Originally Posted by lucidsystems (Post 440576)
Under Mac OS 10.5.1 the networksetup command is able to configure the AirPort. However, you must not enable or disable the power within the script unless you include a long time out.

When you connect to a wireless network using the AirPort menu item, the wireless access point password is stored in both the user and the System Keychains. However, using the networksetup command the wireless access point password is not stored within the System or User Keychains. Dose anyone know of a command which will do the same thing as connecting via the GUI?

We are able to add the password to to an unlocked keychain with the help of the security command. However, our current stumbling block is adding the password to the locked /Library/Keycahins/System.keychain via the command line, without resetting the system Keychain to a known password.

How are others automatically configuring the KeyChain and AirPort, with out cloning the machine?

Thank you all the best.
The Lucid Team.


--
Lucid Information Systems
http://www.lucidsystems.org


tlarkin 02-19-2008 12:15 PM

in 10.5 there is a network setup binary in /usr/sbin/networksetup

If you read through the man pages you can script network settings. I have done this in Tiger with the ARD binary to set proxy settings, and it worked. Now, in 10.5 Apple just decided to make it a part of BASH instead of it being specific to ARD.

elcode 02-20-2008 11:35 AM

10.5 does not retain the scripted airport settings
 
Thanks a lot for the reply!
For some reason in 10.5 the networksetup command works only until laptop goes to sleep or reboots, even if we have the Airport Preferences set to "Remember any network this computer has joined".
That checkbox does not seem to work the same way as it did in Tiger. I am not sure if it is a bug or not, but any 10.5 laptop that I have tried to set up with the networksetup command does not retain the airport settings upon reboot or wake up from sleep.

Quote:

Originally Posted by tlarkin (Post 452476)
in 10.5 there is a network setup binary in /usr/sbin/networksetup

If you read through the man pages you can script network settings. I have done this in Tiger with the ARD binary to set proxy settings, and it worked. Now, in 10.5 Apple just decided to make it a part of BASH instead of it being specific to ARD.


astro666 06-04-2008 07:17 AM

Same Issue
 
Hello All -
Know this has been dead for a while, but am having the same problem. We have changed over the wireless network and need to migrate all users over to the new one - I am pushing out a .pkg that updaing a few things that need to be fixed and some other odds and ends, but we need to get it to join the new WPA wireless network.

The networksetup command joins it to the wireless network, as alluded to above, but doesnt actually put the network in preferred networks list or saves it in system keychain :( I've shot this question off to 3 Apple SE's to see if they can conjour an answer - we shall soon see!

Anyone got any traction with another solution not mentioned above?

tlarkin 06-04-2008 10:14 AM

You know what you need to do, and this is the best $100 you'll ever spend. Go buy composer. Take a snap shot of a system just like the ones on your network, select capture new and modified files. Make all configuration changes, and then take another snap shot.

Build a package. Edit the contents to take out any user level preferences.

Deploy it via ARD or whatever means

Done.

http://www.jamfsoftware.com/products/composer.php

I use this all the time, and it is a superb product.

astro666 06-04-2008 10:21 AM

Results...
 
Hi,

Thanks for the reply - well i've been using packagemaker and its got a 'add snapshot package' utility which i have been playing with - doing basically the same thing. I can then remove the keychain/preferred network, run the package, repair permissions, and then it all re-appears! I just find it a little strange, as system.keychain is one of the files it's 'editing' - now the question is - is this just a delta change? Or is it replacing the whole file? When I get back to work i'll test on a spare MBP, and then if they pick up my home wireless network settings then i'll know ;)

The other problem is its actually changing the systempreferences.plist - again the same issue, is it just delta or replacement? If its replacement then it will wipe the users settings with mine!

I'll check out composer, as that may solve my woes, however any advice with PackageMaker would be great.... i'm very dubious about the system.keychain change - I would be very surprised if OS X allowed an app to modify the system keychain without any issues.....

Thanks,
Mark


All times are GMT -5. The time now is 08:01 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.