aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-09-18 12:47:46 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-09-18 12:47:46 -0300
commit529cd5077e3d76c1d5b612bc146ab174d7143c30 (patch)
treeda86fdf7c5e9fa6ebf752ffdd6515400057757a8 /bin
downloaddebian-529cd5077e3d76c1d5b612bc146ab174d7143c30.tar.gz
debian-529cd5077e3d76c1d5b612bc146ab174d7143c30.tar.bz2
Squashed 'puppet/' content from commit bb2eae6
git-subtree-dir: puppet git-subtree-split: bb2eae6f3a1f44fef0a05000d79c298442fa24c7
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dependencies28
-rwxr-xr-xbin/mrconfig29
-rwxr-xr-xbin/provision21
-rwxr-xr-xbin/submodules31
-rwxr-xr-xbin/subtrees41
-rwxr-xr-xbin/symlinks24
6 files changed, 174 insertions, 0 deletions
diff --git a/bin/dependencies b/bin/dependencies
new file mode 100755
index 0000000..78ca659
--- /dev/null
+++ b/bin/dependencies
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Simple shell provisioner for Vagrant instances.
+#
+
+# Install a package, thanks to the Hydra Suite.
+function provision_package {
+ if [ -z "$1" ]; then
+ return
+ fi
+
+ dpkg -s $1 &> /dev/null
+
+ if [ "$?" == "1" ]; then
+ echo "Installing package $1..."
+ DEBIAN_FRONTEND=noninteractive $sudo apt-get install $1 -y
+ fi
+}
+
+# Set sudo config
+if [ "`whoami`" != 'root' ]; then
+ sudo="sudo"
+fi
+
+# Ensure basic packages are installed.
+for package in puppet ruby-hiera-puppet mr whois; do
+ provision_package $package
+done
diff --git a/bin/mrconfig b/bin/mrconfig
new file mode 100755
index 0000000..ffb0438
--- /dev/null
+++ b/bin/mrconfig
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Build a mrconfig for the needed modules.
+#
+
+# Parameters
+GIT="git.sarava.org"
+URL="https://$GIT/?a=project_index"
+CWD="`pwd`"
+WORK="`dirname $0`/.."
+
+# Create a new config
+cd $WORK
+rm -f .mrconfig
+touch .mrconfig
+
+# Fetch repository list and updtate mrconfig
+curl --stderr - $URL | grep "^puppet-" | while read module; do
+ folder="`echo $module | sed -e 's/^puppet-//'`"
+ folder="`basename $folder .git`"
+
+ if [ "$module" != "$bootstrap" ];
+ echo "Processing $folder..."
+ mr config puppet/modules/$folder checkout="git clone git://$GIT/$module $folder"
+ fi
+done
+
+# Teardown
+cd $CWD
diff --git a/bin/provision b/bin/provision
new file mode 100755
index 0000000..7fa056b
--- /dev/null
+++ b/bin/provision
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Simple shell provisioner for Vagrant instances.
+#
+
+# Ensure the system is updated.
+sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean
+
+# Install dependencies
+source /vagrant/puppet/bin/dependencies
+
+# Ensure additional dependencies are installed.
+for package in sqlite3 libsqlite3-ruby libactiverecord-ruby ruby-sqlite3 usbutils; do
+ provision_package $package
+done
+
+# Make sure we have an initial hiera configuration.
+if [ ! -h "/etc/puppet/hiera.yaml" ]; then
+ sudo rm -f /etc/puppet/hiera.yaml
+ sudo ln -s /vagrant/puppet/hiera/hiera.yaml /etc/puppet/hiera.yaml
+fi
diff --git a/bin/submodules b/bin/submodules
new file mode 100755
index 0000000..f79b635
--- /dev/null
+++ b/bin/submodules
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Setup submodules.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+
+# Usage
+function usage {
+ echo "Usage: $1 add-submodules <DIR>"
+ exit $2
+}
+
+# Get module list
+repos="`grep = $DIRNAME/../.mrconfig | cut -d = -f 2 | cut -d ' ' -f 4`"
+
+# Add submodules
+for repo in $repos; do
+ module="`basename $repo .git | sed -e s/^puppet-//`"
+ if [ ! -d "modules/$module" ]; then
+ echo "Processing puppet module $module..."
+ git submodule add $repo modules/$module
+ elif [ -e "modules/$module/.git" ]; then
+ # The puppet module exists and is a git submodule, so update it
+ ( cd module/$module && git pull origin master )
+ fi
+done
+
+# Update all modules
+git submodule update --init
diff --git a/bin/subtrees b/bin/subtrees
new file mode 100755
index 0000000..1858a48
--- /dev/null
+++ b/bin/subtrees
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Setup subtrees.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+
+# Usage
+function usage {
+ echo "Usage: $1 add-submodules <DIR>"
+ exit $2
+}
+
+# Check for git-subtree
+if ! which git-subtree &> /dev/null; then
+ echo "fatal: please install git-subtree"
+ exit 1
+fi
+
+# Get module list
+repos="`grep = $DIRNAME/../.mrconfig | cut -d = -f 2 | cut -d ' ' -f 4`"
+
+# Add subtrees
+for repo in $repos; do
+ module="`basename $repo .git | sed -e s/^puppet-//`"
+ if [ ! -d "modules/$module" ]; then
+ echo "Processing puppet module $module..."
+ git remote add $module $repo
+ git subtree add --prefix modules/$module $module master --squash
+ elif [ ! -d "modules/$module/.git" ]; then
+ # The puppet module exists and is a subtree, so update it
+ if ! git remote | grep -qe "^$module$"; then
+ git remote add $module $repo
+ fi
+
+ # Update subtrees
+ git fetch $module master
+ git subtree pull --prefix modules/$module $module master --squash
+ fi
+done
diff --git a/bin/symlinks b/bin/symlinks
new file mode 100755
index 0000000..0a221c4
--- /dev/null
+++ b/bin/symlinks
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Setup symlinks.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+MODULES="$1"
+
+# Check parameters
+if [ -z "$MODULES" ]; then
+ echo "Usage: $BASENAME <submodules-folder>"
+ exit 1
+elif [ ! -e "$MODULES" ]; then
+ echo "Not found: $MODULES"
+fi
+
+# Add module symlinks using absolute folders
+for module in `ls $MODULES`; do
+ if [ "$module" != "bootstrap" ]; then
+ path="`cd $MODULES/$module && pwd`"
+ ( cd modules &> /dev/null && ln -sf $path )
+ fi
+done