fixtehinternets

My wife’s laptop runs Debian, and it’s pretty stable. But there is one issue that is proving to be a real pain: the wireless adapter – an Intel job – occasionally detatches itself from the AP for no apparent reason. Obviously this is not a good scenario and something I had to address; I hate getting support calls from home.
My “solution” was to write a little script for her that fixes the problem by taking the interface down and bringing it up again. Now all she has to do is type “fixtehinternets” and it’ll come back up.
Earlier today I was telling my work colleagues about this little hack, and their reaction was totally unexpected; they wanted a copy for their wives! Mr K even suggested I publish the script for the benefit of the google. So, with the caveat that it’s a piece of crap, here is the valuable code:

#!/bin/sh
echo "O HAI! I CAN HAS UR PASSWORDZ ?"
echo "AHM IN UR WIREZ, FIXING UR INTERNETS"
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up
sudo iwconfig wlan0 essid "myssid"
sleep 2
sudo route add default gw 192.168.x.x
ping 158.x.x.x -c 1 >/dev/null 2>&1
[ $? -eq 0 ] && echo "YAY U HAVE ALL TEH INTERNETS!!!" || echo "O NOES! IT ARE BROKE STILL"
echo KTHXBYE

Now, you’ll either not understand a word of that, or you’ll recognise it as the quality piece of genius that it is.
Use it wisely, and not for evil.


Leave a Reply