Skip to content

Instantly share code, notes, and snippets.

@pniaps
Last active February 28, 2019 08:48
Show Gist options
  • Save pniaps/10725e58b0f00e860f7ba13fcc16e8c8 to your computer and use it in GitHub Desktop.
Save pniaps/10725e58b0f00e860f7ba13fcc16e8c8 to your computer and use it in GitHub Desktop.
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