diff --git a/ssh_tools/README.md b/ssh_tools/README.md index d31bd35..f3ed071 100644 --- a/ssh_tools/README.md +++ b/ssh_tools/README.md @@ -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 diff --git a/ssh_tools/multicopy.sh b/ssh_tools/multicopy.sh index 081074e..df12b71 100755 --- a/ssh_tools/multicopy.sh +++ b/ssh_tools/multicopy.sh @@ -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