]> gitweb.fluxo.info Git - hydra.git/commitdiff
Fixing basic command line evaluation
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 1 Nov 2010 16:17:59 +0000 (14:17 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 1 Nov 2010 16:17:59 +0000 (14:17 -0200)
hydra
lib/hydra/misc
share/hydra/register

diff --git a/hydra b/hydra
index fcb3e626a130b4b8cdc9be6d09ed208cd3d0d7d4..f8d695afcc1b9dbba184c7c2115e20384339e7a7 100755 (executable)
--- a/hydra
+++ b/hydra
@@ -49,19 +49,24 @@ function hydra_load {
   source $APP_BASE/lib/hydra/functions || exit 1
 }
 
-# Command-line parameters
+# Basename
 BASENAME="`basename $0`"
-ACTION="$1"
+
+# Adjust hydra parameter
+if [ "$BASENAME" == "hydra" ]; then
+  export HYDRA="$1"
+  shift
+fi
+
+# Load
+hydra_load $*
 
 # Command-line parser
 if [ -z "$ACTION" ]; then
-  echo "usage: $BASENAME <command> [arguments]"
+  echo "usage: $BASENAME [hydra] <command> [arguments]"
   exit 1
 fi
 
-# Load functions
-hydra_load $*
-
 # Dispatch
 if hydra_has_action $ACTION; then
   hydra_dispatch $*
index 5691465378fa54c446daa0ca482b518f02b6bdaf..88ffec16bafdeb5f837c9a45f0257ef94dcf32ae 100644 (file)
@@ -44,28 +44,27 @@ function hydra_config {
 
 # Check if there is a given action
 function hydra_has_action {
- if [ -z "$ACTIONS" ]; then
-   echo "Your have to set ACTIONS variable in the code"
-   exit 1
- fi
 if [ -z "$ACTIONS" ]; then
+    echo "Your have to set ACTIONS variable in the code"
+    exit 1
 fi
 
- if [ -e "$ACTIONS/$1" ]; then
-   true
- else
-   false
- fi
 if [ -e "$ACTIONS/$1" ]; then
+    true
 else
+    false
 fi
 }
 
 # Execute an action
 function hydra_exec {
   # Setup
   action="$1"
-  basedir="$2"
   shift 2
   
   # Dispatch
   if hydra_has_action $action; then
-    $ACTIONS/$action $basedir $*
+    $ACTIONS/$action $*
   fi
 }
 
@@ -75,6 +74,8 @@ function hydra_set_env {
     echo "Error: missing arguments for hydra_set_env"
     exit 1    
   fi
+
+  ACTION="$1"
 }
 
 # Get a command argument
@@ -100,15 +101,5 @@ function hydra_action_usage {
 }
 
 function hydra_dispatch {
-  BASEDIR="`hydra_config $KEYRING`"
-
-  # Dispatch
-  if [ ! -z "$BASEDIR" ]; then
-    shift 2
-    hydra_exec $ACTION $BASEDIR $*
-    exit $?
-  else
-    echo "No keydir configured for $KEYRING"
-    exit 1
-  fi
+  hydra_exec $ACTION $*
 }
index bf36540544fa2389264fdc01b12a39120b7e66d4..677a73db1f18ff40979b655ae4f6c7f66fe7eef2 100755 (executable)
@@ -4,17 +4,20 @@
 #
 
 CONFIG="$HOME/.hydra/config"
-HYDRA="$1"
-BASEDIR="$2"
-PUPPET="$(dirname `find $BASEDIR -name puppet.conf`)"
+BASEDIR="$1"
 
-mkdir -p `dirname $CONFIG`
-
-if grep -q -e "^$HYDRA=" $CONFIG; then
+if [ -z "$BASEDIR" ]; then
+  echo "Usage: hydra [hydra] register <path>"
+  exit 1
+elif grep -q -e "^$HYDRA=" $CONFIG &> /dev/null; then
   echo "Hydra $HYDRA already defined"
   exit 1
 fi
 
+# Folder setup
+#PUPPET="$(dirname `find $BASEDIR -name puppet.conf`)"
+mkdir -p `dirname $CONFIG`
+
 # Reparse basedir to force absolute folder
 BASEDIR="`cd $BASEDIR && pwd`"