to be run */10 * * * * from cron
#!/bin/bash
wlan='wlan0'
gateway='192.168.1.1'
ping -c2 $gateway 2>&1 >/dev/null; rc=$?
if [[ $rc -eq 0 ]] ; then
echo `date +"%b %d %T "`$0": The network is up."
else
echo `date +"%b %d %T "`$0": Network down! Attempting reconnection."
if [ -f /storage/.cache/nonet ]; then
rm -f /storage/.cache/nonet
reboot
fi
ifdown $wlan
rmmod brcmfmac
sleep 2
modprobe brcmfmac brcmfmac_wcc
ifup --force $wlan
sleep 2
connmanctl connect wifi_dc345a1743d_6e6545675289d3567_managed_psk &>/dev/null
sleep 10
ping -c2 $gateway 2>&1 >/dev/null; rc=$?
if [[ $rc -ne 0 ]] ; then
echo "1" > /storage/.cache/nonet
fi
fi
exit 0