Skip to content

Commit 2b2d2e3

Browse files
committed
Merge branch 'helthcheck'
* helthcheck: bug-fix: - networkが繋がらない状態の時にudhcpcが終わらない 機能追加: - retryを繰り返しても接続できない時に再起動する - 再起動時にhealthcheck.logに状態の出力を追加
2 parents 52140fb + 46f51f4 commit 2b2d2e3

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

configs/overlay_rootfs/scripts/health_check.sh

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/sh
22

3-
[ ! -f /tmp/router_address ] && exit 0
43
[ -f /tmp/healthcheck.lock ] && exit 0
54
touch /tmp/healthcheck.lock
65

76
RES=1
8-
ROUTER=`cat /tmp/router_address`
7+
[ -f /tmp/router_address ] && ROUTER=`cat /tmp/router_address`
98
if [ "$ROUTER" = "" ]; then
109
ip route | awk '/default/ { print $3 }' > /tmp/router_address
1110
ROUTER=`cat /tmp/router_address`
@@ -23,19 +22,36 @@ if [ $RES -eq 1 ] ; then
2322
fi
2423

2524
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#* }
2829
let retry++
2930
echo $(date +"%Y/%m/%d %H:%M:%S : retry : ") $retry >> /media/mmc/healthcheck.log
3031
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
3249
ifconfig wlan0 down
3350
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+
3853
fi
54+
echo $retry $error > /tmp/healthcheck.retry_count
3955
else
4056
rm -f /tmp/healthcheck.retry_count
4157
fi

0 commit comments

Comments
 (0)