summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydra/mass39
l---------share/hydra/mass-update1
l---------share/hydra/mass-upgrade1
3 files changed, 41 insertions, 0 deletions
diff --git a/share/hydra/mass b/share/hydra/mass
index bda6e98..410e36d 100755
--- a/share/hydra/mass
+++ b/share/hydra/mass
@@ -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
index 0000000..698f7d4
--- /dev/null
+++ b/share/hydra/mass-update
@@ -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
index 0000000..698f7d4
--- /dev/null
+++ b/share/hydra/mass-upgrade
@@ -0,0 +1 @@
+mass \ No newline at end of file