[ssh_tools] multicopy: formatting, typos, usage

This commit is contained in:
Matteo Cypriani 2019-10-21 15:18:21 +02:00
parent 0e865d9025
commit 8ae30d5e91
1 changed files with 13 additions and 14 deletions

View File

@ -26,15 +26,20 @@ print_usage()
{
cat <<EOF
Usage:
$0 [-P] [-r|-R] [-l login] <hosts_list> <file1> [file2 [...]]
$0 -h
$0 [-P] [-r|-R] [-l <login>] <hosts_list> <file1> [file2 [...]]
Options:
-h Print this help message.
-l <login>
Login remotely as <login>.
-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).
<hosts_list> 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