mirror of
https://github.com/samba-team/samba.git
synced 2024-12-28 07:21:54 +03:00
229846cdd2
(This used to be ctdb commit a3fdaebf1a90ff3c2843a592f6c657a8eae42975)
44 lines
702 B
Bash
Executable File
44 lines
702 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
|
|
if [ -f "$SCRIPT" ]; then
|
|
ssh $a at -f $SCRIPT now
|
|
else
|
|
ssh $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 $a at -f $SCRIPT now
|
|
else
|
|
exec ssh $a $SCRIPT
|
|
fi
|