blob: ec1231616e896407299a69b934a85d8649a0455e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/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
|