Browse Source

[enh] Transform into ash script by Jyhem

ljf 6 years ago
parent
commit
5dba64b2c5
1 changed files with 19 additions and 15 deletions
  1. 19 15
      smart-reboot.sh

+ 19 - 15
smart-reboot.sh

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