diff options
author | James Pannacciulli <jpnc@jpnc.info> | 2015-04-18 23:04:21 -0700 |
---|---|---|
committer | James Pannacciulli <jpnc@jpnc.info> | 2015-04-18 23:04:21 -0700 |
commit | 59ee1f87b7a555addffad3cc9c0b0ba181f24f74 (patch) | |
tree | 3869b46c67ce037788b20cb560f8f4e9f9027b8a | |
parent | 3bcc58bad297439a4f320dfc0bb11971728e7184 (diff) | |
download | parssh-59ee1f87b7a555addffad3cc9c0b0ba181f24f74.tar.gz parssh-59ee1f87b7a555addffad3cc9c0b0ba181f24f74.tar.bz2 |
parameterize ssh '-o' config options with '-c' flag, reorder arg parsing
-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."\ ""\ |