1
1
#! /bin/sh
2
2
3
- [ ! -f /tmp/router_address ] && exit 0
4
3
[ -f /tmp/healthcheck.lock ] && exit 0
5
4
touch /tmp/healthcheck.lock
6
5
7
6
RES=1
8
- ROUTER=` cat /tmp/router_address`
7
+ [ -f /tmp/router_address ] && ROUTER=` cat /tmp/router_address`
9
8
if [ " $ROUTER " = " " ]; then
10
9
ip route | awk ' /default/ { print $3 }' > /tmp/router_address
11
10
ROUTER=` cat /tmp/router_address`
@@ -23,19 +22,36 @@ if [ $RES -eq 1 ] ; then
23
22
fi
24
23
25
24
if [ $RES -eq 0 ] ; then
26
- retry=0
27
- [ -f /tmp/healthcheck.retry_count ] && retry=` cat /tmp/healthcheck.retry_count`
25
+ retry_count=" 0 0"
26
+ [ -f /tmp/healthcheck.retry_count ] && retry_count=` cat /tmp/healthcheck.retry_count`
27
+ retry=${retry_count% * }
28
+ error=${retry_count#* }
28
29
let retry++
29
30
echo $( date +" %Y/%m/%d %H:%M:%S : retry : " ) $retry >> /media/mmc/healthcheck.log
30
31
if [ $retry -ge 3 ] ; then
31
- echo $( date +" %Y/%m/%d %H:%M:%S : WiFi restart" ) >> /media/mmc/healthcheck.log
32
+ retry=0
33
+ let error++
34
+ if [ $error -ge 10 ] ; then
35
+ echo $( date +" %Y/%m/%d %H:%M:%S : retry error -> reboot" ) >> /media/mmc/healthcheck.log
36
+ echo router=$ROUTER >> /media/mmc/healthcheck.log
37
+ [ " $ROUTER " != " " ] && ping -c 1 $ROUTER >> /media/mmc/healthcheck.log 2>&1
38
+ ping -c 1 8.8.8.8 >> /media/mmc/healthcheck.log 2>&1
39
+ ifconfig wlan0 >> /media/mmc/healthcheck.log 2>&1
40
+ df -k >> /media/mmc/healthcheck.log
41
+ free >> /media/mmc/healthcheck.log
42
+ killall -SIGUSR2 iCamera_app
43
+ sync
44
+ sync
45
+ sync
46
+ reboot
47
+ fi
48
+ echo $( date +" %Y/%m/%d %H:%M:%S : WiFi restart : error : " ) $error >> /media/mmc/healthcheck.log
32
49
ifconfig wlan0 down
33
50
ifconfig wlan0 up
34
- killall -USR1 udhcpc || udhcpc -i wlan0 -p /var/run/udhcpc.pid
35
- rm -f /tmp/healthcheck.retry_count
36
- else
37
- echo $retry > /tmp/healthcheck.retry_count
51
+ killall -USR1 udhcpc || udhcpc -i wlan0 -n -p /var/run/udhcpc.pid >> /media/mmc/healthcheck.log 2>&1
52
+
38
53
fi
54
+ echo $retry $error > /tmp/healthcheck.retry_count
39
55
else
40
56
rm -f /tmp/healthcheck.retry_count
41
57
fi
0 commit comments