People who want to autologin on a Telenet Hotspot with their MacBook, here’s a recipe you can use for that.
By far the most reliable way to do this is using crankd that, in a very similar way to launchd, allows you to run scripts in response to events such as network changes, filesystem activity, and application launching. The process to get started is not terribly complicated, but it requires some editing of system files.
- First lets make a script that will handle the login. Open up an editor and put the following in:
#!/bin/sh
tn_user=YOUR HOTSPOT LOGIN
tn_pass=YOUR HOTSPOT PASSWD
CURL=`which curl`
SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
if [ "$SSID" = "TELENETHOTSPOT" ]; then
$CURL -v -L -d checkterms=1 -d terms=on -d c=std -d lang=nl -d userid=$tn_user -d password=$tn_pass "https://portal.telenethotspot.be/logon/welcome.jsp";
fi
- Save that file somewhere, let’s say i saved it in:
/Users/cjpa/scripts/autologin_tnhotspot.sh
- Download and install PyMacAdmin, this includes crankd.
- Once installed, open a terminal and run
/usr/local/sbin/crankd.py
. If for some reason it crashes with an error about an undefined NSNotificationHandler
, don’t worry. You can safely disregard that. If it didn’t crash type Ctrl+C to exit the program. The important point is that it would have created an example configuration file in:
~/Library/Preferences/com.googlecode.pymacadmin.crankd.plist
.
- Open the configuration file in a text editor and modify it so that it looks like the following:
<?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>SystemConfiguration</key>
<dict>
<key>State:/Network/Global/IPv4</key>
<dict>
<key>command</key>
<string>/Users/cjpa/scripts/autologin_tnhotspot.sh</string>
</dict>
</dict>
</dict>
</plist>
- Now we can try it. Run
/usr/local/sbin/crankd.py
in a terminal and disconnect your wireless. Reconnect again and check in the console if you get output like this: INFO: SystemConfiguration: State:/Network/Global/IPv4: executing /Users/cjpa/scripts/autologin_tnhotspot.sh
- If you do, everything is in working order and we are ready to set crankd to start automatically on reboot.
- Let’s make a file
~/Library/LaunchAgents/org.crankd.plist
and put the following in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.crankd.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/crankd.py</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
- We have created a launchd item which will start everytime your laptop boots. You can start it manually with the following command:
launchctl load ~/Library/LaunchAgents/org.crankd.plist
- That’s It! Now go look for a hotspot..
Based on the following blogpost: http://qscripts.blogspot.com/2011/03/run-script-in-os-x-on-network.html