From ad682e05f5765530ec273df8df45cde6c523322a Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 13 Nov 2013 14:04:17 +1100 Subject: [PATCH] onnode: New -i option to stop stdin from being closed This can be useful for piping data to onnode in certain circumstances. There are now also enough command-line options that they should definitely be alphabetically ordered. Signed-off-by: Martin Schwenke --- doc/onnode.1.xml | 12 ++++++++++++ tools/onnode | 15 ++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/onnode.1.xml b/doc/onnode.1.xml index 561764c1..ec878031 100644 --- a/doc/onnode.1.xml +++ b/doc/onnode.1.xml @@ -68,6 +68,18 @@ + -i + + + Keep standard input open, allowing data to be piped to + onnode. Normally onnode closes stdin to avoid surprises + when scripting. Note that this option is ignored when + using or if SSH is set + to anything other than "ssh". + + + + -n diff --git a/tools/onnode b/tools/onnode index 0abc1363..33d0e207 100755 --- a/tools/onnode +++ b/tools/onnode @@ -31,13 +31,14 @@ usage () Usage: onnode [OPTION] ... ... options: -c Run in current working directory on specified nodes. + -f Specify nodes file, overrides CTDB_NODES_FILE. + -i Keep standard input open - the default is to close it. + -n Allow nodes to be specified by name. -o Save standard output from each node to file . -p Run command in parallel on specified nodes. + -P Push given files to nodes instead of running commands. -q Do not print node addresses (overrides -v). - -n Allow nodes to be specified by name. - -f Specify nodes file, overrides CTDB_NODES_FILE. -v Print node address even for a single node. - -P Push given files to nodes instead of running commands. "all", "any", "ok" (or "healthy"), "con" (or "connected"), "rm" (or "recmaster"), "lvs" (or "lvsmaster"), "natgw" (or "natgwlist"); or @@ -64,6 +65,7 @@ quiet=false prefix="" names_ok=false push=false +stdin=false ctdb_base="${CTDB_BASE:-/etc/ctdb}" @@ -74,7 +76,7 @@ parse_options () # options ot onnode. local temp # Not on the previous line - local returns 0! - temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqvP" -l help -- "$@") + temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqvPi" -l help -- "$@") [ $? != 0 ] && usage @@ -90,6 +92,7 @@ parse_options () -q) quiet=true ; shift ;; -v) verbose=true ; shift ;; -P) push=true ; shift ;; + -i) stdin=true ; shift ;; --) shift ; break ;; -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable. esac @@ -367,7 +370,9 @@ else [ -r "${ctdb_base}/onnode.conf" ] && . "${ctdb_base}/onnode.conf" [ -n "$SSH" ] || SSH=ssh if [ "$SSH" = "ssh" ] ; then - ssh_opts="-n" + if $parallel || ! $stdin ; then + ssh_opts="-n" + fi else : # rsh? All bets are off! fi -- 2.34.1