Print SSH connection errors only if no server is available.
This commit is contained in:
parent
075f35e1a0
commit
c2cbcb23b4
|
@ -50,6 +50,9 @@ export LANG=C
|
||||||
## Force umask
|
## Force umask
|
||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
|
## Initialize variable to store SSH connection errors
|
||||||
|
SERVERS_SSH_ERRORS=""
|
||||||
|
|
||||||
# Call test_server with "HOST:PORT" string
|
# Call test_server with "HOST:PORT" string
|
||||||
# It will return with 0 if the server is reachable.
|
# It will return with 0 if the server is reachable.
|
||||||
# It will return with 1 and a message on stderr if not.
|
# It will return with 1 and a message on stderr if not.
|
||||||
|
@ -67,7 +70,9 @@ test_server() {
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
# SSH connection failed
|
# SSH connection failed
|
||||||
echo "Failed to connect to \`${item}' within ${SSH_CONNECT_TIMEOUT} seconds" >&2
|
new_error=$(printf "Failed to connect to \`%s' within %s seconds" "${item}" "${SSH_CONNECT_TIMEOUT}")
|
||||||
|
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -78,7 +83,10 @@ pick_server() {
|
||||||
|
|
||||||
if [ "${increment}" -ge "${list_length}" ]; then
|
if [ "${increment}" -ge "${list_length}" ]; then
|
||||||
# We've reached the end of the list
|
# We've reached the end of the list
|
||||||
echo "No more server available" >&2
|
new_error="No more server available"
|
||||||
|
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
|
printf "%s\n" "${SERVERS_SSH_ERRORS}" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue