summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/misc27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 4695d5f..d83afbb 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -2,11 +2,13 @@
# Setup main configuration and load preferences
function hydra_config_load {
- if [ -f "$HOME/.$NAME" ]; then
+ local folder="`dirname $CONFIG`"
+
+ if [ -f "$folder" ]; then
echo "Converting legacy configuration scheme..."
- mv $HOME/.$NAME $HOME/.$NAME.tmp
- mkdir $HOME/.$NAME
- mv $HOME/.$NAME.tmp $CONFIG
+ mv $folder $folder.tmp
+ mkdir -p $folder
+ mv $folder.tmp $CONFIG
fi
if [ ! -e "$CONFIG" ]; then
@@ -23,10 +25,20 @@ function hydra_config_load {
# Load config preferences
function hydra_config_load_preferences {
- # Load custom keyring preferences
+ # Load custom preferences
if [ ! -z "$PREFERENCES" ] && [ -f "$PREFERENCES" ]; then
source $PREFERENCES
fi
+
+ hydra_check_preferences
+}
+
+# Check preferences
+function hydra_check_preferences {
+ if [ ! -z "$PUPPET" ] && [ ! -d "$PUPPET" ]; then
+ echo "Puppet folder not found: $PUPPET."
+ exit 1
+ fi
}
# Load a parameter from config
@@ -70,7 +82,12 @@ function hydra_exec {
# Set needed environment variables and do basic checks.
function hydra_set_env {
+ export CONFIG="$HOME/.hydra/config"
export ACTION="$1"
+
+ if [ ! -z "$HYDRA" ]; then
+ export PREFERENCES="$HOME/.hydra/$HYDRA"
+ fi
}
# Get a command argument