diff options
author | Martin Schwenke <martin@meltin.net> | 2018-02-27 12:12:45 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2018-03-01 19:39:15 +0100 |
commit | d1ff94686ab7541827f9b8e0e40899d5cf5a4c83 (patch) | |
tree | 045ab414b71c882008b7e21de6a15ab6a07fb842 /ctdb | |
parent | 254a18422c567a591d7e99ff6d1d0678d985c5fa (diff) | |
download | samba-d1ff94686ab7541827f9b8e0e40899d5cf5a4c83.tar.gz |
ctdb-tests: Add fake ssh command for local daemons tests
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/simple/scripts/ssh_local_daemons.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ctdb/tests/simple/scripts/ssh_local_daemons.sh b/ctdb/tests/simple/scripts/ssh_local_daemons.sh new file mode 100755 index 00000000000..ecf5ee952f2 --- /dev/null +++ b/ctdb/tests/simple/scripts/ssh_local_daemons.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +nodes="${CTDB_NODES:-${CTDB_BASE}/nodes}" + +# ssh options can't be used so discard them +while : ; do + case "$1" in + -*) shift ;; + *) break ;; + esac +done + +if [ $# -ne 2 ] ; then + echo "usage: $0 <ip> <command>" >&2 + exit 1 +fi + +# IP adress of node. onnode can pass hostnames but not in these tests +ip="$1" +# Complete command is provide by onnode as a single argument +command="$2" + +num=$(awk -v ip="$ip" '$1 == ip { print NR }' "$nodes") +pnn=$((num - 1)) + +# Determine the correct Unix domain socket +export CTDB_SOCKET="" +n=0 +for s in $CTDB_NODES_SOCKETS ; do + if [ $n -eq $pnn ] ; then + CTDB_SOCKET="$s" + break + fi + n=$((n + 1)) +done +if [ -z "$CTDB_SOCKET" ] ; then + echo "$0: Unable to find socket for node ${ip}" >&2 + exit 1 +fi + +# Now +exec sh -c "$command" |