Changeset d052914 in freewrt for package/busybox/files/if-watchdog


Ignore:
Timestamp:
Mar 1, 2007, 7:43:52 PM (19 years ago)
Author:
Markus Wigge <markus@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
de7e642
Parents:
1334083d
Message:
  • added optional ping check to the interface watchdog
  • documented watchdog in interfaces file

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@2119 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package/busybox/files/if-watchdog

    r1334083d rd052914  
    22
    33INTERFACE="$1"
     4REMOTE_IP="$2"
    45
    56FAIL_COUNT=0
     
    78
    89while :; do
    9     LINK_OK=0
    10     if ip addr show "$INTERFACE" 2>/dev/null | grep -q UP; then
    11         LINK_OK=1
    12     fi
    13     if [ $LINK_OK -eq 0 ]; then
    14         FAIL_COUNT=$((FAIL_COUNT+1))
    15     else
    16         FAIL_COUNT=0
    17     fi
    18     if [ $FAIL_COUNT -ge $FAIL_LIMIT ]; then
    19         /sbin/reboot -f
    20     fi
    21     sleep 60
     10        LINK_OK=0
     11        if ip addr show "$INTERFACE" 2>/dev/null | grep -q UP; then
     12                LINK_OK=1
     13        fi
     14        if [ $LINK_OK -eq 0 ]; then
     15                FAIL_COUNT=$((FAIL_COUNT+1))
     16        else
     17                if [ -n "$REMOTE_IP" ]; then
     18                        if ping -c 1 -q $REMOTE_IP >/dev/null 2>&1; then
     19                                FAIL_COUNT=0
     20                        else
     21                                FAIL_COUNT=$((FAIL_COUNT+1))
     22                                logger "$0: remote IP not pingable, FAIL_COUNT: $FAIL_COUNT"
     23                        fi
     24                else
     25                        FAIL_COUNT=0
     26                fi
     27        fi
     28        if [ $FAIL_COUNT -ge $FAIL_LIMIT ]; then
     29                /sbin/reboot -f
     30        fi
     31        sleep 60
    2232done
Note: See TracChangeset for help on using the changeset viewer.