]> gitweb.fluxo.info Git - hydra.git/commitdiff
Checking availability of commands
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 28 Sep 2011 22:12:55 +0000 (19:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 28 Sep 2011 22:12:55 +0000 (19:12 -0300)
lib/hydra/misc
share/hydra/mass

index 5b342144d3092343b3e9e2e0606ab012ee0083b3..98d16ac857ec97a27035ff69450ea9f365fe0fd6 100644 (file)
@@ -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
+}
index 3aebd2207c2d7b9183392c21d3dc14098d851f6f..9bd83f9545372b045311115cf6751977fca46281 100755 (executable)
@@ -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"
 }