]> gitweb.fluxo.info Git - hydra.git/commitdiff
Initial working version of a mass dispatcher
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Nov 2010 15:53:09 +0000 (13:53 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 13 Nov 2010 15:53:09 +0000 (13:53 -0200)
share/hydra/mass
share/hydra/mass-update [new symlink]
share/hydra/mass-upgrade [new symlink]

index bda6e984648b219b6fa10dd440d4983bdde71f1d..410e36d2baca114d8177c1a020f2e21189776e94 100755 (executable)
@@ -2,3 +2,42 @@
 #
 # Execute commands on multiple nodes.
 #
+
+# Issue commands with pssh
+function mass_pssh {
+  hydra_set_tmpfile nodes
+  hydra $HYDRA nodes > $TMPWORK
+  parallel-ssh -h $TMPWORK -p 4 $COMMAND
+  hydra_unset_tmpfile $TMPWORK
+}
+
+# Issue commands with a for loop
+function mass_loop {
+  for node in $NODES; do
+    echo "Connecting to $node..."
+    ssh -o ConnectTimeout=15 $node $COMMAND
+  done
+}
+
+# Load functions
+source $APP_BASE/lib/hydra/functions || exit 1
+
+# Load config
+hydra_config_load
+
+# Command line arguments
+BASENAME="`basename $0`"
+COMMAND="$*"
+
+# Validation
+if [ "$BASENAME" == "mass-update" ]; then
+  COMMAND="sudo aptitude update"
+elif [ "$BASENAME" == "mass-update" ]; then
+  COMMAND="sudo aptitude safe-upgrade"
+fi
+
+# Build node list
+NODES="`hydra $HYDRA nodes`"
+
+# Execute commands in hosts
+mass_loop $COMMAND
diff --git a/share/hydra/mass-update b/share/hydra/mass-update
new file mode 120000 (symlink)
index 0000000..698f7d4
--- /dev/null
@@ -0,0 +1 @@
+mass
\ No newline at end of file
diff --git a/share/hydra/mass-upgrade b/share/hydra/mass-upgrade
new file mode 120000 (symlink)
index 0000000..698f7d4
--- /dev/null
@@ -0,0 +1 @@
+mass
\ No newline at end of file