Browse Source

[enh] Script to reboot a openwrt antenna

ljf 6 years ago
parent
commit
cdab4cd1e3
1 changed files with 31 additions and 0 deletions
  1. 31 0
      smart-reboot.sh

+ 31 - 0
smart-reboot.sh

@@ -0,0 +1,31 @@
+#!/bin/bash
+
+FLAG = /etc/no-smart-reboot
+IP = 89.234.141.73
+
+function fix_by_rebooting () {
+    touch $FLAG
+    # Update time at boot
+    touch /etc/banner
+    reboot
+}
+
+
+# See here to understand why this sleep 70
+# https://openwrt.org/docs/guide-user/base-system/cron#periodic_reboot_of_a_router
+sleep 70
+if [ -e $FLAG ]; then
+    if ping -c10 -i3 -q $IP > /dev/null ; then
+        rm -f $FLAG
+    elif [ "$(date +%M)" = "42" ]; then
+        fix_by_rebooting
+    elif [ "$(date +%M)" = "12" ]; then
+        fix_by_rebooting
+    fi
+else
+    if ! ping -c2 -q $IP > /dev/null ; then
+        fix_by_rebooting
+    elif [ "$(date +%H%M)" = "0430" ]; then
+        fix_by_rebooting
+    fi
+fi