best pracitces to add wifi network to user’s login.keychain?
I am thinking about deploying a launch agent that runs as the user logs in, as the user to add our wifi network to the keychain. Thoughts?
[code] #!/bin/bash
# set user's login.keychain to have our wifi passsword
# run this as the user, via user agent
/usr/bin/security find-generic-password -a usd500_wpa
case `/bin/echo $?` in
0 )) hasloginkeychain=yes;;
* )) hasloginkeychain=no;;
esac
if [[ $hasloginkeychain -eq yes ]]
then /usr/bin/security add-generic-password -a usd500_wpa -s AirPort -D "AirPort network password" -l usd500_wpa -w mypasskey -T /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -T /usr/libexec/airportd -U ~/Library/Keychains/login.keychain
else /usr/bin/security add-generic-password -a usd500_wpa -s AirPort -D "AirPort network password" -l usd500_wpa -w mypasskey -T /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -T /usr/libexec/airportd -A ~/Library/Keychains/login.keychain
fi
exit 0 [/code]
Thoughts, suggestions, pointers, better methods all welcome.
Thanks in advance!
Tom