Skip to content

Instantly share code, notes, and snippets.

@kokoye2007
Last active December 11, 2015 11:07
Show Gist options
  • Save kokoye2007/b8161fdcc604c133a8bd to your computer and use it in GitHub Desktop.
Save kokoye2007/b8161fdcc604c133a8bd to your computer and use it in GitHub Desktop.
#!/bin/bash
# The IP for the server you wish to ping (8.8.8.8 is a public Google DNS server)
SERVER=8.8.8.8
# The Ethernet or Wlan or Ath Address
NETWORKFACE=wlan0
# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
then
# Restart the wireless interface
ifdown --force $NETWORKFACE
ifup $NETWORKFACE
fi
@kokoye2007
Copy link
Author

chmod +x /usr/local/bin/wifi-auto-connect

/etc/crontab
*/5 * * * * root /usr/local/bin/wifi-auto-connect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment