diff options
-rw-r--r-- | lib/hydra/action | 7 | ||||
-rw-r--r-- | lib/hydra/misc | 1 | ||||
-rwxr-xr-x | share/hydra/module-verify | 33 |
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/hydra/action b/lib/hydra/action index b5d76a9..868f301 100644 --- a/lib/hydra/action +++ b/lib/hydra/action @@ -41,3 +41,10 @@ function hydra_get_command { function hydra_dispatch { hydra_exec $ACTION $* } + +# Evaluate a parameter from the config file +function hydra_eval_parameter { + if [ -e "$CONFIG" ] && grep -qe "^$1=" $CONFIG; then + grep -e "^$1=" $CONFIG | tail -n 1 | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//' + fi +} diff --git a/lib/hydra/misc b/lib/hydra/misc index f0bf210..90dd4b8 100644 --- a/lib/hydra/misc +++ b/lib/hydra/misc @@ -6,6 +6,7 @@ function hydra_set_env { export ACTION="$1" if [ ! -z "$HYDRA" ]; then + export HYDRA_FOLDER="`hydra_eval_parameter $HYDRA`" export PREFERENCES="$HOME/.hydra/$HYDRA" fi } diff --git a/share/hydra/module-verify b/share/hydra/module-verify new file mode 100755 index 0000000..81afbfe --- /dev/null +++ b/share/hydra/module-verify @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Verify a puppet module +# + +# Load +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +MODULE="$1" + +if [ -z "$1" ]; then + exit +elif [ -z "$HYDRA_FOLDER" ] || [ ! -e "$HYDRA_FOLDER/modules" ]; then + echo "Please make a symlink $HYDRA_FOLDER/modules pointing to your devel puppet modules." + exit 1 +fi + +cd $PUPPET +HASH_SUBMODULE="`git submodule | grep "modules/$MODULE " | awk '{ print $1 }'`" + +cd $HYDRA_FOLDER/modules/$MODULE + +HASH_MODULE="`git log -1 | grep "^commit" | awk '{ print $2 }'`" + +if [ "$HASH_MODULE" != "$HASH_SUBMODULE" ]; then + echo "Module $MODULE: hash differ!!:" + echo "Module: $HASH_MODULE" + echo "Submodule: $HASH_SUBMODULE" + exit 1 +fi + +echo "Latest commit hash match." |