1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00
samba-mirror/ctdb/tools/onnode.ssh
Andrew Tridgell 5d9913642f allow remote variable expansion in onnode, so you can use wildcards that expand on the remote nodes
(This used to be ctdb commit def643225a1cb31d4999f3e73fad368ae60048ad)
2008-01-09 15:04:56 +11:00

45 lines
751 B
Bash
Executable File

#!/bin/sh
# onnode script for ssh
if [ $# -lt 2 ]; then
cat <<EOF
Usage: onnode <nodenum|all> <command>
EOF
exit 1
fi
NODE="$1"
shift
SCRIPT="$@"
NODES=/etc/ctdb/nodes
NUMNODES=`egrep '^[[:alnum:]]' $NODES | wc -l`
MAXNODE=`expr $NUMNODES - 1`
if [ $NODE = "all" ]; then
for a in `egrep '^[[:alnum:]]' $NODES`; do
echo; echo ">> NODE: $a <<"
if [ -f "$SCRIPT" ]; then
ssh -n $a at -f "$SCRIPT" now
else
ssh -n $a "$SCRIPT"
fi
done
exit 0
fi
if [ $NODE -gt $MAXNODE ]; then
echo "Node $NODE doesn't exist"
exit 1
fi
NODEPLUSONE=`expr $NODE + 1`
a=`egrep '^[[:alnum:]]' $NODES | head -$NODEPLUSONE | tail -1`
if [ -f "$SCRIPT" ]; then
exec ssh -n $a at -f "$SCRIPT" now
else
exec ssh -n $a "$SCRIPT"
fi