summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-06-18 15:12:10 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-06-18 15:12:10 -0300
commit018170210556e910c89ffec813bf516b65ded253 (patch)
tree06326284a91acddf940d9d6c0ef621b3678e5057
parenta52dd4933d2771c65836423ffcdfe4c2dee29b96 (diff)
downloadhydra-018170210556e910c89ffec813bf516b65ded253.tar.gz
hydra-018170210556e910c89ffec813bf516b65ded253.tar.bz2
Cleanup module helpers
-rwxr-xr-xshare/hydra/module-add61
-rwxr-xr-xshare/hydra/module-branch37
-rwxr-xr-xshare/hydra/module-commit45
-rwxr-xr-xshare/hydra/module-update61
-rwxr-xr-xshare/hydra/module-verify49
5 files changed, 0 insertions, 253 deletions
diff --git a/share/hydra/module-add b/share/hydra/module-add
deleted file mode 100755
index 1bc8cb1..0000000
--- a/share/hydra/module-add
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-#
-# Add puppet modules
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# Load
-source $APP_BASE/lib/hydra/functions || exit 1
-hydra_config_load
-
-# Parameters
-DOMAIN="`facter domain`"
-
-# Add a module
-function hydra_module_add {
- # Command line arguments
- MODULE="$1"
-
- # Validation
- if [ -z "$MODULE" ]; then
- echo "Usage: hydra <hydra> module-add <module> [<module1> ... <moduleN>]"
- exit 1
- elif [ -d "$PUPPET/modules/$MODULE" ]; then
- echo "Module $MODULE already added at $HYDRA puppet configuration."
- exit 1
- fi
-
- # Update the module
- ( cd $PUPPET ; git submodule add git://git.$DOMAIN/puppet-$MODULE modules/$MODULE )
- ( cd $PUPPET ; git commit -a -m "Adding $MODULE module" )
-
- # Verify the module
- if ! hydra $HYDRA module-verify $MODULE; then
- echo "ERROR: Updated module doesn't match hash, please verify and update manually."
- exit 1
- fi
-
- # Commit
- ( cd $PUPPET; git push )
-}
-
-# Main loop
-for module in $*; do
- echo "Adding module $module at puppet repository..."
- hydra_module_add $module
-done
-
-# Initialize everything
-( cd $PUPPET ; git submodule update --init --recursive )
diff --git a/share/hydra/module-branch b/share/hydra/module-branch
deleted file mode 100755
index dc03276..0000000
--- a/share/hydra/module-branch
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-#
-# Change branch of a puppe module
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# Load
-source $APP_BASE/lib/hydra/functions || exit 1
-hydra_config_load
-
-MODULE="$1"
-BRANCH=${2:=master}
-
-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
-
-# Update the module
-(
- cd $PUPPET/modules/$MODULE
- git checkout $BRANCH
-)
diff --git a/share/hydra/module-commit b/share/hydra/module-commit
deleted file mode 100755
index 01603ec..0000000
--- a/share/hydra/module-commit
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-#
-# Commit and update a puppet module
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# Load
-source $APP_BASE/lib/hydra/functions || exit 1
-hydra_config_load
-
-MODULE="$1"
-
-# Push to repositories
-function hydra_git_push {
- if [ "`git remote | wc -l`" == "0" ]; then
- return
- elif git remote | grep -q 'all'; then
- git push all --all
- elif git remote | grep -q 'origin'; then
- git push --all
- fi
-}
-
-if [ -d "$HYDRA_FOLDER/modules/$MODULE" ]; then
- shift
- echo "Commiting changes at $MODULE module..."
- ( cd "$HYDRA_FOLDER/modules/$MODULE" && git commit -a -m "$*" && hydra_git_push )
- echo ""
- hydra $HYDRA module-update $MODULE
-else
- echo "No such module $MODULE"
- exit 1
-fi
diff --git a/share/hydra/module-update b/share/hydra/module-update
deleted file mode 100755
index d0f1472..0000000
--- a/share/hydra/module-update
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-#
-# Update puppet modules
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# Load
-source $APP_BASE/lib/hydra/functions || exit 1
-hydra_config_load
-
-function hydra_module_update {
- # Command line arguments
- MODULE="$1"
-
- # Validation
- if [ -z "$MODULE" ]; then
- echo "Usage: hydra <hydra> module-update <module> [<module1> ... <moduleN>]"
- exit 1
- elif [ ! -d "$PUPPET/modules/$MODULE" ]; then
- echo "No such module $MODULE at $HYDRA puppet configuration."
- exit 1
- fi
-
- # Update the module
- (
- cd $PUPPET/modules/$MODULE
-
- # Ensure the submodule has a branch
- if git branch | head -1 | grep -q -E "no branch|detached"; then
- git checkout master
- fi
-
- git pull
- )
-
- # Verify the module
- if ! hydra $HYDRA module-verify $MODULE; then
- echo "ERROR: Updated module doesn't match hash, please verify and update manually."
- exit 1
- fi
-
- # Commit
- ( cd $PUPPET; git commit -a -m "Updates module $MODULE"; git push )
-}
-
-for module in $*; do
- echo "Updates module $module at puppet repository..."
- hydra_module_update $module
-done
diff --git a/share/hydra/module-verify b/share/hydra/module-verify
deleted file mode 100755
index 19cfd73..0000000
--- a/share/hydra/module-verify
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-#
-# Verify a puppet module
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# 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 -E "modules/$MODULE( |$)" | awk '{ print $1 }' | \
- sed -e 's/\+//' -e 's/-//'`"
-
-cd $HYDRA_FOLDER/modules/$MODULE
-
-BRANCH="`git branch`"
-HASH_MODULE="`git log -1 | grep "^commit" | awk '{ print $2 }' | sed -e 's/\+//'`"
-
-if [ "$HASH_MODULE" != "$HASH_SUBMODULE" ]; then
- echo "Module $MODULE: hash differ!!:"
- echo "Module: $HASH_MODULE"
- echo "Submodule: $HASH_SUBMODULE"
- echo "Branch: $BRANCH"
- exit 1
-fi
-
-echo "Commit check successful for $MODULE module."