Skip to content

Instantly share code, notes, and snippets.

@oofnikj
Created December 27, 2019 21:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#!/bin/bash
# Script to reset wifi on a Raspberry Pi Zero W
# Outputs a message to systemd-journal every time it resets
#
# nothing else seemed to work
#
# Run it with crontab every minute
GATEWAY_IP=$(/sbin/ip -4 route | grep default | awk '{print $3}')
_am_i_online() {
ping -D -c3 $GATEWAY_IP
}
_fix_it() {
echo "can't reach gateway! unloading / reloading wifi kernel module" | systemd-cat -t $(basename $0)
# shutdown -r
/sbin/modprobe -r brcmfmac
/sbin/modprobe brcmfmac
}
_am_i_online || _fix_it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment