aboutsummaryrefslogtreecommitdiffstats
path: root/pars.sh
diff options
context:
space:
mode:
authorJames Pannacciulli <jpnc@jpnc.info>2015-04-18 23:04:21 -0700
committerJames Pannacciulli <jpnc@jpnc.info>2015-04-18 23:04:21 -0700
commit59ee1f87b7a555addffad3cc9c0b0ba181f24f74 (patch)
tree3869b46c67ce037788b20cb560f8f4e9f9027b8a /pars.sh
parent3bcc58bad297439a4f320dfc0bb11971728e7184 (diff)
downloadparssh-59ee1f87b7a555addffad3cc9c0b0ba181f24f74.tar.gz
parssh-59ee1f87b7a555addffad3cc9c0b0ba181f24f74.tar.bz2
parameterize ssh '-o' config options with '-c' flag, reorder arg parsing
Diffstat (limited to 'pars.sh')
-rw-r--r--pars.sh59
1 files changed, 34 insertions, 25 deletions
diff --git a/pars.sh b/pars.sh
index f89615c..253d686 100644
--- a/pars.sh
+++ b/pars.sh
@@ -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."\
""\