[ssh_tools] multicopy: don't require multiping

This commit is contained in:
Matteo Cypriani 2019-10-21 16:37:56 +02:00
parent 2b47bb65d2
commit eed73bf99f
2 changed files with 18 additions and 12 deletions

View File

@ -95,8 +95,8 @@ remote files that are not in the local copy will be deleted (rsync's
Please note that unlike rsync, prsync cannot handle multiple local files,
therefore the `-P` option is ignored when passed along with `-r` or `-R`.
**Dependencies**: `parallel-scp` (`pscp`), `parallel-rsync` (`prsync`),
`multiping` (see above)
**Dependencies (optional)**: `parallel-scp` (`pscp`), `parallel-rsync`
(`prsync`), `multiping` (see above)
**Ansible replacement**: use Ansible `copy` module. See also modules `fetch`
(to retrieve files instead of pushing them), `synchronize`, `rsync` and

View File

@ -129,9 +129,9 @@ fi
MULTIPING=$(command -v multiping)
if [ -z "$MULTIPING" ] ; then
err "multiping (which should have been provided along with this" \
"script) is required for this script to work."
exit $EXIT_DEPENDENCY
warn "multiping (which should have been provided along with this" \
"script) is not available. For best results, make sure it is" \
"reachable from your PATH."
fi
# Hosts list file
@ -153,14 +153,20 @@ if [ -n "$LOGIN" ] ; then
LOGIN="-l $LOGIN"
fi
# Test the connection to the first alive host and get the destination
# directory (home directory of the remote user)
FIRST_HOST=$($MULTIPING "$HOSTS_LIST_NAME" 2>/dev/null \
| sed -n "s/ is alive$//p" | head -n1)
if [ -z "$FIRST_HOST" ] ; then
err "None of the remote hosts is alive."
exit $EXIT_HOSTS_DEAD
# Test the connection to the first alive host
if [ -n "$MULTIPING" ] ; then
FIRST_HOST=$($MULTIPING "$HOSTS_LIST_NAME" 2>/dev/null \
| sed -n "s/ is alive$//p" | head -n1)
if [ -z "$FIRST_HOST" ] ; then
err "None of the remote hosts is alive."
exit $EXIT_HOSTS_DEAD
fi
else # multiping is not available
warn "multiping is not available, using the first host in the hosts list."
FIRST_HOST="$(grep -v '^#' "$HOSTS" | head -n 1)"
fi
# Get the destination directory (home directory of the remote user)
echo "Testing connection to $FIRST_HOST..."
DEST_DIR="$(ssh "${SSH_LOGIN}${FIRST_HOST}" 'echo $HOME' 2>/dev/null)"
if [ -z "$DEST_DIR" ] ; then