|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#!/bin/sh |
|
|
|
|
# |
|
|
|
|
# cluster-deploy.sh, Copyright © 2013 Matteo Cypriani <mcy@lm7.fr> |
|
|
|
|
# multicopy.sh, Copyright © 2013 Matteo Cypriani <mcy@lm7.fr> |
|
|
|
|
# (Formerly named cluster-deploy.sh) |
|
|
|
|
# |
|
|
|
|
# This program is free software. It comes without any warranty, to |
|
|
|
|
# the extent permitted by applicable law. You can redistribute it |
|
|
|
@ -53,7 +54,7 @@ done
|
|
|
|
|
|
|
|
|
|
# Do we still have at least a host list and a file? |
|
|
|
|
# Note: if the program was wrongly called but still has 2 arguments, for |
|
|
|
|
# example with "cluster-deploy -l root -P my_file", it will try to use |
|
|
|
|
# example with "multicopy -l root -P my_file", it will try to use |
|
|
|
|
# "-P" as hosts' list and "my_file" as the file to be transfered. |
|
|
|
|
if [ $# -lt 2 ] ; then |
|
|
|
|
print_usage |
|
|
|
@ -81,15 +82,15 @@ fi
|
|
|
|
|
# Check dependencies |
|
|
|
|
PSCP=$(command -v parallel-scp || command -v pscp.pssh || command -v pscp) |
|
|
|
|
PRSYNC=$(command -v parallel-rsync || command -v prsync) |
|
|
|
|
CLUSTERPING=$(command -v cluster-ping) |
|
|
|
|
MULTIPING=$(command -v multiping) |
|
|
|
|
if [ -z "$RSYNC" ] && [ -z "$PSCP" ] ; then |
|
|
|
|
echo "Parallel SSH (pssh) is required for this script to work." |
|
|
|
|
exit 4 |
|
|
|
|
elif [ -z "$PRSYNC" ] ; then |
|
|
|
|
echo "Parallel rsync (prsync) is required for this script to work." |
|
|
|
|
exit 5 |
|
|
|
|
elif [ -z "$CLUSTERPING" ] ; then |
|
|
|
|
echo "cluster-ping (which should have been provided along with this" |
|
|
|
|
elif [ -z "$MULTIPING" ] ; then |
|
|
|
|
echo "multiping (which should have been provided along with this" |
|
|
|
|
echo "script) is required for this script to work." |
|
|
|
|
exit 6 |
|
|
|
|
fi |
|
|
|
@ -99,7 +100,7 @@ HOSTS_LIST_NAME="$1"
|
|
|
|
|
if [ -z "$XDG_CONFIG_HOME" ] ; then |
|
|
|
|
XDG_CONFIG_HOME="$HOME/.config" |
|
|
|
|
fi |
|
|
|
|
HOSTS="$XDG_CONFIG_HOME/cluster/${HOSTS_LIST_NAME}.lst" |
|
|
|
|
HOSTS="$XDG_CONFIG_HOME/ssh_tools/${HOSTS_LIST_NAME}.lst" |
|
|
|
|
shift |
|
|
|
|
echo "Using file '$HOSTS' as hosts' list." |
|
|
|
|
if [ ! -f "$HOSTS" ] ; then |
|
|
|
@ -116,7 +117,7 @@ fi
|
|
|
|
|
|
|
|
|
|
# Test the connection to the first host and get the destination |
|
|
|
|
# directory (home directory of the remote user) |
|
|
|
|
FIRST_HOST=$($CLUSTERPING "$HOSTS_LIST_NAME" 2>/dev/null \ |
|
|
|
|
FIRST_HOST=$($MULTIPING "$HOSTS_LIST_NAME" 2>/dev/null \ |
|
|
|
|
| sed -n "s/ is alive$//p" | head -n1) |
|
|
|
|
if [ -z "$FIRST_HOST" ] ; then |
|
|
|
|
echo "None of the remote hosts is alive." |
|
|
|
|