freewrt_2_0
| Line | |
|---|
| 1 | #! /bin/sh
|
|---|
| 2 |
|
|---|
| 3 | INTERFACE="$1"
|
|---|
| 4 | REMOTE_IP="$2"
|
|---|
| 5 |
|
|---|
| 6 | FAIL_COUNT=0
|
|---|
| 7 | FAIL_LIMIT=3
|
|---|
| 8 |
|
|---|
| 9 | while :; 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
|
|---|
| 32 | done
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.