diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:20:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:20:00 +0000 |
commit | 8daa83a594a2e98f39d764422bfbdbc62c9efd44 (patch) | |
tree | 4099e8021376c7d8c05bdf8503093d80e9c7bad0 /ctdb/tests/UNIT/eventscripts/stubs/rpcinfo | |
parent | Initial commit. (diff) | |
download | samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.tar.xz samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.zip |
Adding upstream version 2:4.20.0+dfsg.upstream/2%4.20.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | ctdb/tests/UNIT/eventscripts/stubs/rpcinfo | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ctdb/tests/UNIT/eventscripts/stubs/rpcinfo b/ctdb/tests/UNIT/eventscripts/stubs/rpcinfo new file mode 100755 index 0000000..8732751 --- /dev/null +++ b/ctdb/tests/UNIT/eventscripts/stubs/rpcinfo @@ -0,0 +1,78 @@ +#!/bin/sh + +prog="rpcinfo" + +usage() +{ + cat >&2 <<EOF +Usage: $prog -T tcp host program [version] + +A fake rpcinfo stub that succeeds for items in FAKE_RPCINFO_SERVICES, +depending on command-line options. + +EOF + exit 1 +} + +parse_options() +{ + while getopts "T:h?" opt; do + case "$opt" in + T) netid="$OPTARG" ;; + \? | h) usage ;; + esac + done + shift $((OPTIND - 1)) + + [ "$netid" = "tcp" ] || usage + + host="$1" + shift + [ "$host" = "localhost" ] || [ "$host" = "127.0.0.1" ] || usage + + if [ $# -lt 1 ] || [ $# -gt 2 ]; then + usage + fi + + p="$1" + v="$2" +} + +parse_options "$@" + +for i in ${FAKE_RPCINFO_SERVICES}; do + # This is stupidly cumulative, but needs to happen after the + # initial split of the list above. + IFS="${IFS}:" + # Want glob expansion + # shellcheck disable=SC2086 + set -- $i + # $1 = program, $2 = low version, $3 = high version + + if [ "$1" = "$p" ]; then + if [ -n "$v" ]; then + if [ "$2" -le "$v" ] && [ "$v" -le "$3" ]; then + echo "program ${p} version ${v} ready and waiting" + exit 0 + else + echo "rpcinfo: RPC: Program/version mismatch; low version = ${2}, high version = ${3}" >&2 + echo "program ${p} version ${v} is not available" + exit 1 + fi + else + for j in $(seq "$2" "$3"); do + echo "program ${p} version ${j} ready and waiting" + done + exit 0 + fi + fi +done + +echo "rpcinfo: RPC: Program not registered" >&2 +if [ -n "$v" ]; then + echo "program ${p} version ${v} is not available" +else + echo "program ${p} is not available" +fi + +exit 1 |