高榮用的 web authentication 和中榮一樣,所以上回寫給中榮用的方法幾乎只要改掉帳號密碼和 URL 即可。
環境: Mac OS X 10.8.3
需安裝 wget,不論是用 MacPorts 或是 Homebrew 安裝即可。
設定 LaunchAgent
~/Library/LaunchAgents/LocationChanger.plist
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>tech.inhelsinki.nl.locationchanger</string> <key>ProgramArguments</key> <array> <string>/Users/USERNAME/bin/locationchanger</string> </array> <key>WatchPaths</key> <array> <string>/Library/Preferences/SystemConfiguration</string> </array> </dict> </plist> |
上面的 USERNAME 請替代為你的 username.
登入用 Script
建立自動登入用 script: ~/bin/locationchanger
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/bin/bash # automatically change configuration of Mac OS X based on location # author: Onne Gorter # modified: Reverb CS Chu # original-url: http://tech.inhelsinki.nl/locationchanger/ # version: 0.4.1 USERNAME="帳號" PASSWORD="密碼" # redirect all IO to /dev/null (comment this out if you want to debug) exec 1>/dev/null 2>/dev/null # get a little breather before we get data for things to settle down sleep 2 # get various system information SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep ' SSID:' | cut -d ':' -f 2 | tr -d ' '` if [ $SSID == "VGHKS-Aruba" ]; then POSTLOGIN="user=$USERNAME&password=$PASSWORD&cmd=authenticate" /opt/local/bin/wget -O- https://securelogin.arubanetworks.com/auth/index.html/u --post-data=$POSTLOGIN -T8 -t2 fi exit 0 |
USERNAME 及 PASSWORD 請填入自己的帳號密碼。
將 script 設定為可執行:
|
1 |
chmod 755 ~/bin/locationchanger |
備註:
- user 和 password 欄位名稱和中榮相同
- 高榮使用 https 加密協定,中榮只用 http。
- 如果 time-out 時間設定太短可能會失敗,所以把 -T 延長到 8 秒。
載入設定檔
重新開機或是手動載入:
|
1 |
launchctl load ~/Library/LaunchAgents/LocationChanger.plist |