From 2ce49691634a67397a198ecfb0ba6e1668d05d3d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 28 Sep 2011 19:12:55 -0300 Subject: Checking availability of commands --- lib/hydra/misc | 12 ++++++++++++ share/hydra/mass | 3 +++ 2 files changed, 15 insertions(+) diff --git a/lib/hydra/misc b/lib/hydra/misc index 5b34214..98d16ac 100644 --- a/lib/hydra/misc +++ b/lib/hydra/misc @@ -45,3 +45,15 @@ function hydra_truncate_database { mysql $1 -e "drop database $1; create database $1;" fi } + +# Check for a command +function hydra_check_command { + if [ -z "$1" ]; then + return + fi + + if ! which $1 &> /dev/null; then + echo "Please install a package for $1 to run this action" + exit 1 + fi +} diff --git a/share/hydra/mass b/share/hydra/mass index 3aebd22..9bd83f9 100755 --- a/share/hydra/mass +++ b/share/hydra/mass @@ -5,6 +5,7 @@ # Issue commands with pssh function mass_pssh { + hydra_check_command parallel-ssh parallel-ssh -t 120 -P -p 4 -h $TMPWORK sudo $COMMAND } @@ -18,11 +19,13 @@ function mass_loop { # Issue commands with dish function mass_dish { + hydra_check_command dish dish -f -p /dev/null -e "sudo $COMMAND" -g $TMPWORK } # Issue commands with mussh function mass_mussh { + hydra_check_command mussh mussh -H $TMPWORK -c "sudo $COMMAND" } -- cgit v1.2.3