🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
Mac OS X: shell程序实现添加无线SSID     2009-10-08:     一个基本的实现脚本, 没有重复/删除/错误检查等处理: yourSSID="TEST"yourPWD="TEST"SecurityType="WEP"WEPOpenSystem=truenetworkUUID=`uuidgen`pwdUUID=`uuidgen`cTime=`date "+%a %b %e %H:%M:%S %Z %Y"`function addSSID_Airport_Pref { # plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "print KnownNetworks" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID dict" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:SecurityType string $SecurityType" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:SSID_STR string $yourSSID" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:'Unique Password ID' string $pwdUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:'Remembered channels' array {0 integer 1}" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:_timeStamp date $cTime" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:WEPOpenSystem bool $WEPOpenSystem"# sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "print KnownNetworks:$networkUUID"}function addPWD_SystemKeychain{# default_keychain = `security default-keychain` security default-keychain -s /Library/Keychain/System.keychain sudo security add-generic-password -a "$yourSSID" -D "AirPort network password" -s "$pwdUUID" -l "$yourSSID" -w "$yourPWD" -j "wireless_setup_v1.0" -A -U# security default-keychain -s $default_keychain security default-keychain -s ""}function addLocation{ currentSet=`plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print CurrentSet"`# currentSet=${currentSet:6} currentSet=${currentSet/////":"} # plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print $currentSet:Network:Interface:en1:AirPort:PreferredNetworks" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0 dict" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:SSID_STR string $yourSSID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:SecurityType string 'WEP'" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:'Unique Newtork ID' string $networkUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:'Unique Password ID' string $pwdUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "set $currentSet:Network:Interface:en1:AirPort:RequireAdmin bool No"# plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0"}function CleanAll{# 1. Delete from preferences.plist currentSet=`plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print CurrentSet"` currentSet=${AA/////":"} sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "delete $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0"#2. Delete Airport_Pref sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "delete KnownNetworks:$networkUUID"#3. Delete Keychain security default-keychain -s /Library/Keychain/System.keychain sudo security add-generic-password -a "$yourSSID" -D "AirPort network password" -s "$pwdUUID" -l "$yourSSID" -w "$yourPWD" -j "wireless_setup_v1.0" -A -U security default-keychain -s ""}ln -f /usr/libexec/PlistBuddy /usr/sbin/plistbuddyaddSSID_Airport_Pref addPWD_SystemKeychainaddLocationlogger "Wireless addition finished successfully."     2009-10-07   这个bash脚本用于企业内部规模部署的时候,无须为了添加无线网络到系统核心影像文件中而设计。   正在编写,成功可能性还是有的, 基本条件已经具备了.