Script to fix Yosemite WiFi breakage

Until Apple fixes the buggy Yosemite WiFi driver I’m running this script I whipped up and it’s helping me keep a tenuous grip on what I’m pleased to call my sanity.

It looks for WiFi to drop out of the “running” state and then power cycles it. Works like a charm.

while :
do
    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I |grep -q running

    if [ $? == 1 ]
    then
        # Not running, reconnect
        echo "$(date): WiFi down .. reconnecting ..."
        networksetup -setairportpower en0 off
        networksetup -setairportpower en0 on
    fi

    sleep 2
done

Result:

Fri Oct 31 13:01:01 PDT 2014: WiFi down .. reconnecting ...
Fri Oct 31 13:28:51 PDT 2014: WiFi down .. reconnecting ...
Fri Oct 31 13:31:01 PDT 2014: WiFi down .. reconnecting ...
Fri Oct 31 13:33:01 PDT 2014: WiFi down .. reconnecting ...
Fri Oct 31 13:52:32 PDT 2014: WiFi down .. reconnecting ...

Best thing about it is that I don’t have to download a tool from a .ru domain and run it as root. What could possibly go wrong?