From 73d18832cb310f4bb026d4101e4669b54de54d8d Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Tue, 27 Jun 2017 22:27:00 +0300 Subject: [PATCH] fix S41netwatch script --- board/common/overlay/etc/init.d/S41netwatch | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index 940d515083..c7421d72f8 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -7,7 +7,9 @@ netwatch_interval=20 test -f $watch_conf && source $watch_conf || exit 0 -test -z "$netwatch_host" || -z "$netwatch_port" && exit 0 +if [ -z "$netwatch_host" ] || [ -z "$netwatch_port" ]; then + exit 0 +fi test -n "$os_version" || source /etc/init.d/base test -n "$os_debug" || source /etc/init.d/conf @@ -18,10 +20,12 @@ watch() { count=0 netwatch_retries=$(($netwatch_retries - 1)) while true; do + sleep $netwatch_interval if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port /dev/null 2>&1; then count=0 else if [ $count -lt $netwatch_retries ]; then + logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port" count=$(($count + 1)) continue else @@ -29,7 +33,6 @@ watch() { reboot fi fi - sleep $netwatch_interval done }