source: freewrt/package/busybox/files/if-watchdog@ 621d5d2

freewrt_2_0
Last change on this file since 621d5d2 was d052914, checked in by Markus Wigge <markus@…>, 19 years ago
  • 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

  • Property mode set to 100755
File size: 559 bytes
Line 
1#! /bin/sh
2
3INTERFACE="$1"
4REMOTE_IP="$2"
5
6FAIL_COUNT=0
7FAIL_LIMIT=3
8
9while :; do
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
32done
Note: See TracBrowser for help on using the repository browser.