smart-reboot.sh 830 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/ash
  2. FLAG=/etc/no-smart-reboot
  3. IP=89.234.141.73
  4. # See here to understand why this sleep 70
  5. # https://openwrt.org/docs/guide-user/base-system/cron#periodic_reboot_of_a_router
  6. sleep 70
  7. if [ -e $FLAG ]; then
  8. if ping -c10 -q $IP > /dev/null ; then
  9. rm -f $FLAG
  10. elif [ "$(date +%M)" = "42" ]; then
  11. touch $FLAG
  12. # Update time at boot
  13. touch /etc/banner
  14. reboot
  15. elif [ "$(date +%M)" = "12" ]; then
  16. touch $FLAG
  17. # Update time at boot
  18. touch /etc/banner
  19. reboot
  20. fi
  21. else
  22. if ! ping -c2 -q $IP > /dev/null ; then
  23. touch $FLAG
  24. # Update time at boot
  25. touch /etc/banner
  26. reboot
  27. elif [ "$(date +%H%M)" = "0430" ]; then
  28. touch $FLAG
  29. # Update time at boot
  30. touch /etc/banner
  31. reboot
  32. fi
  33. fi