aboutsummaryrefslogtreecommitdiff
path: root/share/hydra/mass
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-11-13 13:53:09 -0200
committerSilvio Rhatto <rhatto@riseup.net>2010-11-13 13:53:09 -0200
commitaad028515f31567af2155c7448201663535000a3 (patch)
tree9bd396c6099918543b6c3cb7dd0feb02cea062d7 /share/hydra/mass
parent88fb3d2d1bcfdc2cf59ca908b80bc40292aa8ed0 (diff)
downloadhydra-aad028515f31567af2155c7448201663535000a3.tar.gz
hydra-aad028515f31567af2155c7448201663535000a3.tar.bz2
Initial working version of a mass dispatcher
Diffstat (limited to 'share/hydra/mass')
-rwxr-xr-xshare/hydra/mass39
1 files changed, 39 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