Skip to content

Instantly share code, notes, and snippets.

@chetan
Created March 18, 2015 16:14
Show Gist options
  • Save chetan/206428059e4ec83effbd to your computer and use it in GitHub Desktop.
Save chetan/206428059e4ec83effbd to your computer and use it in GitHub Desktop.
Script to fix WIFI issues on the Raspberry Pi B+
#!/bin/bash
# The raspberrypi would occasionally lose WIFI.
# The fix is to reset the interface manually or reboot the device.
#
# Script should be run as root and run every 5 min:
# crontab:
# */5 * * * * /root/bin/fix_wifi.sh
PATH="/sbin:$PATH"
ifconfig wlan0 | grep -q "inet addr:"
ret=$?
if [ $ret -ne 0 ] ; then
logger 'WIFI connection down! Attempting reconnection.'
ifdown --force wlan0
sleep 10
ifup --force wlan0
sleep 10
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment