summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-08-10 13:12:49 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-08-10 13:12:49 -0300
commit683c19ba6468926f7e5fa354cb0c75c2900250cb (patch)
tree5de8e1f3f4453b4518ed1e7a328c6e38cadc0639
parenta726a236c0b5c55447e6734b83f5465366824f9f (diff)
downloadhydra-683c19ba6468926f7e5fa354cb0c75c2900250cb.tar.gz
hydra-683c19ba6468926f7e5fa354cb0c75c2900250cb.tar.bz2
Adding module-verify action
-rw-r--r--lib/hydra/action7
-rw-r--r--lib/hydra/misc1
-rwxr-xr-xshare/hydra/module-verify33
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."