add errorcode when nc not found

This commit is contained in:
Jakobus Schürz 2020-10-19 14:35:07 +02:00
parent b6db22c888
commit 1531ccd9ae

View file

@ -678,9 +678,13 @@ reachable-default () {
local SERVER=$1
local PORT=${2:-22}
local res=3
if which nc >/dev/null; then
if nc -w 2 -z $SERVER $PORT 2>/dev/null; then
res=0
fi
else
res=2
fi
return $res
}
@ -688,6 +692,7 @@ reachable () {
ENTRY
# returncodes:
# 1: servername not resolveable
# 2: command nc not found
# 3: server:port not reachable
# 999999: something went wrong
# 0: server was resolve- and reachable