fix S41netwatch script

This commit is contained in:
Calin Crisan 2017-06-27 22:27:00 +03:00 committed by GitHub
parent 956d7d0b2a
commit 73d18832cb

View File

@ -7,7 +7,9 @@ netwatch_interval=20
test -f $watch_conf && source $watch_conf || exit 0 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_version" || source /etc/init.d/base
test -n "$os_debug" || source /etc/init.d/conf test -n "$os_debug" || source /etc/init.d/conf
@ -18,10 +20,12 @@ watch() {
count=0 count=0
netwatch_retries=$(($netwatch_retries - 1)) netwatch_retries=$(($netwatch_retries - 1))
while true; do while true; do
sleep $netwatch_interval
if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then
count=0 count=0
else else
if [ $count -lt $netwatch_retries ]; then if [ $count -lt $netwatch_retries ]; then
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port"
count=$(($count + 1)) count=$(($count + 1))
continue continue
else else
@ -29,7 +33,6 @@ watch() {
reboot reboot
fi fi
fi fi
sleep $netwatch_interval
done done
} }