]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
moved onnode into ctdb from s3 examples/ctdb
authorAndrew Tridgell <tridge@samba.org>
Wed, 30 May 2007 01:00:43 +0000 (11:00 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 30 May 2007 01:00:43 +0000 (11:00 +1000)
(This used to be ctdb commit a3fdaebf1a90ff3c2843a592f6c657a8eae42975)

ctdb/packaging/RHEL/ctdb.spec
ctdb/tools/onnode.rsh [new file with mode: 0644]
ctdb/tools/onnode.ssh [new file with mode: 0755]

index b3334bac7194c64a489ca6a574ed9e64e24e06fb..af05333a52eb4ba16954ea550ec8439aa3bce48b 100644 (file)
@@ -66,6 +66,9 @@ make DESTDIR=$RPM_BUILD_ROOT install
 install -m644 setup/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
 install -m755 setup/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb
 install -m755 tools/events $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/events
+install -m755 tools/onnode.ssh $RPM_BUILD_ROOT%{_bindir}
+install -m755 tools/onnode.rsh $RPM_BUILD_ROOT%{_bindir}
+ln -sf %{_bindir}/onnode.ssh onnode
 
 # unfortunately samba3 needs ctdb_private.h too
 install -m644 include/ctdb_private.h %{_includedir}/ctdb_private.h
diff --git a/ctdb/tools/onnode.rsh b/ctdb/tools/onnode.rsh
new file mode 100644 (file)
index 0000000..cdda325
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+# onnode script for rsh
+
+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
+           rsh $a at -f $SCRIPT now
+       else
+           rsh $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 rsh $a at -f $SCRIPT now
+else
+    exec rsh $a $SCRIPT
+fi
diff --git a/ctdb/tools/onnode.ssh b/ctdb/tools/onnode.ssh
new file mode 100755 (executable)
index 0000000..ec12316
--- /dev/null
@@ -0,0 +1,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