diff --git a/ssh_tools/multicopy.sh b/ssh_tools/multicopy.sh index 293065a..fb8860c 100755 --- a/ssh_tools/multicopy.sh +++ b/ssh_tools/multicopy.sh @@ -26,15 +26,20 @@ print_usage() { cat < [file2 [...]] + $0 -h + $0 [-P] [-r|-R] [-l ] [file2 [...]] Options: -h Print this help message. + -l + Login remotely as . -P Transfer files in parallel instead of one by one whenever possible (ignored when -r or -R is used). -r Use prsync instead of pscp. -R Use prsync's --delete option (delete remote files that are not in the local copy). + + is the list of remote hosts on which the file(s) will be copied. EOF } @@ -76,15 +81,11 @@ done shift $((OPTIND - 1)) # Do we still have at least a host list and a file? -if [ $# -lt 2 ] ; then - bad_usage "Wrong number of arguments." -fi +[ $# -lt 2 ] && bad_usage "Wrong number of arguments." # Check the usage of -r and -R if [ "$DELETE" = "1" ] ; then - if [ "$RSYNC" = "1" ] ; then - bad_usage "Use either -r or -R, but not both." - fi + [ "$RSYNC" = "1" ] && bad_usage "Use either -r or -R, but not both." RSYNC=1 DELETE="-X --delete" fi @@ -113,16 +114,14 @@ if [ -z "$MULTIPING" ] ; then exit $EXIT_DEPENDENCY fi -# Hosts' list file +# Hosts list file HOSTS_LIST_NAME="$1" -if [ -z ${XDG_CONFIG_HOME+x} ] ; then - XDG_CONFIG_HOME="$HOME/.config" -fi -HOSTS="$XDG_CONFIG_HOME/ssh_tools/${HOSTS_LIST_NAME}.lst" shift -echo "Using file '$HOSTS' as hosts' list." +[ -z ${XDG_CONFIG_HOME+x} ] && XDG_CONFIG_HOME="$HOME/.config" +HOSTS="$XDG_CONFIG_HOME/ssh_tools/${HOSTS_LIST_NAME}.lst" +echo "Using file '$HOSTS' as hosts list." if [ ! -f "$HOSTS" ] ; then - err "The hosts' list file doesn't exist or is not a regular file." + err "The hosts list file doesn't exist or is not a regular file." exit $EXIT_HOSTS_LIST fi