Created
December 27, 2019 21:48
-
-
Save oofnikj/9b653e58d1f887fc166b7eb700e327b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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