public
Created

MacbookPro5,1 has a serious problem with it's wireless. Apple will not acknowledge it, but here's a fix

  • Download Gist
nettest.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#!/bin/sh
#
# Tests network status and resets Airport if required
#
usage() {
cat << EOF
Usage: $0 options
 
-h HOST host to ping
-s <ON|OFF> say out loud: on or off default: OFF
 
EOF
}
 
SAY=OFF
gateway=`netstat -rn | grep default | tr -s " " | cut -d " " -f 2`
 
while getopts "hH:sS" OPTION
do
case $OPTION in
h)
gateway=$OPTARG
;;
s)
SAY=$OPTARG
;;
?)
usage
exit 1
esac
done
 
fix=1
 
if [ `whoami` != root ]; then
echo "You should be root to run this"
exit 1
fi
 
echo ""
echo "Will ping $gateway"
echo ""
 
while [ 1 = 1 ]; do
varStatus=`ping -c 1 -t 2 $gateway | grep "loss"| cut -d , -f 3 | tr -s " "`
lastStatus=$failed
failed=`echo $varStatus | grep "100" -c`
printf "."
if [ $failed = 1 ]; then
if [ $fix = 1 ]; then
if [ "$SAY" = "ON" ]; then
say "Lost connection." &
else
afplay /System/Library/Sounds/Submarine.aiff &
fi
/usr/sbin/networksetup -setairportpower en1 off
/usr/sbin/networksetup -setairportpower en1 on
varDate=`date +"%Y-%m-%d %H:%M:%S"`
varIp=`ifconfig en1 inet | grep inet | tr -s " " | cut -d " " -f 2`
echo ""
echo "$varDate | $varIp | Restarted"
sleep 12
echo Channel: $(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep channel | tr -s " " | cut -d " " -f 3)
else
printf "X"
fi
else
if [ "$lastStatus" = "1" ]; then
if [ "$SAY" = "ON" ]; then
say "Restored" &
fi
fi
fi
sleep 3
done
echo ""
echo "---------------------------------"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.