From aad028515f31567af2155c7448201663535000a3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 13 Nov 2010 13:53:09 -0200 Subject: Initial working version of a mass dispatcher --- share/hydra/mass | 39 +++++++++++++++++++++++++++++++++++++++ share/hydra/mass-update | 1 + share/hydra/mass-upgrade | 1 + 3 files changed, 41 insertions(+) create mode 120000 share/hydra/mass-update create mode 120000 share/hydra/mass-upgrade (limited to 'share') 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 -- cgit v1.2.3