summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhydra17
-rw-r--r--lib/hydra/misc35
-rwxr-xr-xshare/hydra/register15
3 files changed, 33 insertions, 34 deletions
diff --git a/hydra b/hydra
index fcb3e62..f8d695a 100755
--- 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 $*
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 5691465..88ffec1 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -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 $*
}
diff --git a/share/hydra/register b/share/hydra/register
index bf36540..677a73d 100755
--- a/share/hydra/register
+++ b/share/hydra/register
@@ -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`"