Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Keep attempting reconnection to wireless network' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep attempting reconnection to wireless network
Authored by: joostjodel on Feb 24, '11 02:41:52PM

Thanks for this command.
To make it make useful for my purposes, that is, trying to reconnect an old Powerbook server that regularly loses its WiFi connection, I cobbled together a few extras:

1. a bash script that can be invoked to check if Airport is still up

#!/bin/bash
## simple script to check whether Airport is still up, and restart it in case it is down.
if ping -W2 -c4 192.168.1.1
then echo "Hurrah, still up in the air…"
else
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport prefs joinmode=automatic joinmodefallback=keeplooking
fi

This pings to your router (mine is on 192.168.1.1 - change if appropriate) and runs the command if no network is up.

I placed this as "airport_up_check.sh" in /usr/local/bin/ (don't forget to run a $chmod 770)

2. run the command visudo and add a few lines under:

# Cmnd alias specification
Cmnd_Alias AIRPORT = /usr/local/bin/airport_up_check.sh

and under:

# User privilege specification
<your usename here> ALL=AIRPORT


3. make a launchd script "local.airport_up_check.plist" with the following content and place it in /Library/LaunchAgents:

<?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>Airport_up_check</key>
<false/>
<key>Label</key>
<string>local.airport_up_check</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/airport_up_check.sh</string>
</array>
<key>StartInterval</key>
<integer>600</integer>
<key>RunAtLoad</key>
<true />
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>

600 means run every 10 minutes (10*60 secs).

then run the command:
$ launchctl load /Library/LaunchAgents/local.airport_up_check.plist




[ Reply to This | # ]