aboutsummaryrefslogtreecommitdiff
path: root/share
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
parent88fb3d2d1bcfdc2cf59ca908b80bc40292aa8ed0 (diff)
downloadhydra-aad028515f31567af2155c7448201663535000a3.tar.gz
hydra-aad028515f31567af2155c7448201663535000a3.tar.bz2
Initial working version of a mass dispatcher
Diffstat (limited to 'share')
-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