Last active
February 28, 2019 08:48
-
-
Save pniaps/10725e58b0f00e860f7ba13fcc16e8c8 to your computer and use it in GitHub Desktop.
wget -O - https://gist.githubusercontent.com/pniaps/10725e58b0f00e860f7ba13fcc16e8c8/raw/f98419c01d70e6fbecf056135ec1ca1167bbed67 | bash
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
cat << 'EOF' > /etc/uci-defaults/reset_wan | |
#!/bin/sh | |
(crontab -l ; echo "*/5 * * * * sh /usr/bin/reset_wan") | sort | uniq | crontab - | |
/etc/init.d/cron start | |
/etc/init.d/cron enable | |
exit 0 | |
EOF | |
chmod +x /etc/uci-defaults/reset_wan | |
cat << 'EOF' > /usr/bin/reset_wan | |
#!/bin/sh | |
tries=0 | |
while [[ $tries -lt 5 ]] | |
do | |
if /bin/ping -c1 -w5 8.8.8.8 > /dev/null | |
then | |
exit 0 | |
fi | |
tries=$((tries+1)) | |
done | |
date >> /root/restarts.txt | |
sleep 10 && reboot | |
EOF | |
chmod +x /usr/bin/reset_wan | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment