Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. wlan='wlan0'
  4. gateway='192.168.1.1'
  5. alias ifup='/sbin/ifup'
  6. alias ifdown='/sbin/ifdown'
  7. alias ifconfig='/sbin/ifconfig'
  8.  
  9. # Only send two pings, sending output to /dev/null as we don't want to fill logs on our sd card.
  10. # If you want to force ping from your wlan0 you can connect next line and uncomment second line
  11. ping -c2 ${gateway} > /dev/null # ping to gateway from Wi-Fi or from Ethernet
  12. # ping -I ${wlan} -c2 ${gateway} > /dev/null # only ping through Wi-Fi
  13.  
  14. # If the return code from ping ($?) is not 0 (meaning there was an error)
  15. if [ $? != 0 ]
  16. then
  17.     # Restart the wireless interface
  18.     ifdown --force wlan0
  19.     ifup wlan0
  20.     sleep 5
  21.     ifup wlan0
  22. fi
  23. ping -I ${wlan} -c2 ${gateway} > /dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement