diff options
-rw-r--r-- | pars.sh | 59 |
1 files changed, 34 insertions, 25 deletions
@@ -30,17 +30,33 @@ parssh () { while [[ "$1" == -* ]]; do case ${1#-} in + -) + shift + break + ;; [0-9]*) [[ "${1#-}" != *[^0-9]* ]] && { local _parssh_concurrency=${1#-} } ;; - s|-servers) - [[ -r "$2" ]] || { - echo "'$2': invalid file name or permissions issue" - return 99 + b|-bare) + unset _parssh_prepend_host + ;; + c|-config) + local _parssh_ssh_config="$2" + shift + ;; + h|-help) + _parssh.usage + return $? + ;; + o|-out) + touch "${2}."{out,err} || { + echo "'${2}.{out,err}': unable to write / modify file" + return 97 } - local _parssh_servers="$2" + local _parssh_outprefix="$2" + local _parssh_outfun=_parssh.out_redirect shift ;; r|-rinput) @@ -52,16 +68,12 @@ parssh () { local _parssh_ssh=_parssh.ssh_rinput shift ;; - b|-bare) - unset _parssh_prepend_host - ;; - o|-out) - touch "${2}."{out,err} || { - echo "'${2}.{out,err}': unable to write / modify file" - return 97 + s|-servers) + [[ -r "$2" ]] || { + echo "'$2': invalid file name or permissions issue" + return 99 } - local _parssh_outprefix="$2" - local _parssh_outfun=_parssh.out_redirect + local _parssh_servers="$2" shift ;; t|-tee) @@ -73,14 +85,6 @@ parssh () { local _parssh_outfun=_parssh.out_copy shift ;; - h|-help) - _parssh.usage - return $? - ;; - -) - shift - break - ;; esac shift done @@ -111,11 +115,12 @@ parssh () { } _parssh.ssh () { - ssh -no StrictHostKeyChecking=no $host -- "$@" + ssh -n ${_parssh_ssh_config+-o} ${_parssh_ssh_config//,/ -o } $host -- "$@" } _parssh.ssh_rinput () { - ssh -To StrictHostKeyChecking=no $host -- "$@" < "$_parssh_rinput" + ssh -T ${_parssh_ssh_config+-o} ${_parssh_ssh_config//,/ -o } $host -- "$@"\ + < "$_parssh_rinput" } _parssh.host_prepend () @@ -142,7 +147,8 @@ _parssh.usage () { "parssh: Parallel SSH orchestration in a Bash session."\ ""\ "SYNOPSIS"\ - "parssh [-NUM] [-r|--rinput FILE] [-s|--servers FILE] [-b|--bare] [COMMANDS] [< SERVERS]"\ + "parssh [-NUM] [-r|--rinput FILE] [-s|--servers FILE] [-b|--bare] [-c|--config]"\ + " [COMMANDS] [< SERVERS]"\ ""\ "DESCRIPTION"\ " -NUM (default: 4)"\ @@ -159,6 +165,9 @@ _parssh.usage () { " -b, --bare (default: unset/inactive)"\ " Disable prepending of hostname to each output line returned by COMMANDS on SERVERS."\ ""\ + " -c, --config (default: unset/inactive)"\ + " Comma separated list of configuration parameters to be passed to SSH via '-o' flag."\ + ""\ " -o PREFIX, --out PREFIX (default: unset/inactive)"\ " Redirect STDOUT / STDERR to PREFIX.out / PREFIX.err, respectively."\ ""\ |