summaryrefslogtreecommitdiff
path: root/bin/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'bin/deploy')
-rwxr-xr-xbin/deploy58
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/deploy b/bin/deploy
new file mode 100755
index 0000000..5d3361b
--- /dev/null
+++ b/bin/deploy
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Deploy configuration using puppet.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+BASEDIR="$DIRNAME/.."
+DEPLOY_DEPENDENCIES="puppet ruby-sqlite3 ruby-activerecord ruby-activerecord-deprecated-finders"
+
+# Determine hostname
+if [ ! -z "$1" ]; then
+ FQDN="$1"
+else
+ FQDN="`cat /etc/hostname`"
+fi
+
+# Check for manifest
+PUPPET_MANIFEST="$BASEDIR/puppet/manifests/nodes/$FQDN.pp"
+if [ ! -e "$PUPPET_MANIFEST" ]; then
+ echo "file not found: $PUPPET_MANIFEST"
+ exit 1
+fi
+
+# Install dependencies
+source $DIRNAME/dependencies
+
+# Ensure additional dependencies are installed.
+for package in $DEPLOY_DEPENDENCIES; do
+ provision_package $package
+done
+
+# Parameters that needs dependencies installed
+DIST="`facter lsbdistcodename`"
+
+# Apply patches
+if [ -d "$BASEDIR/puppet/files/patches/$DIST" ]; then
+ (
+ # Patches should be generated relativelly to the root folder
+ cd /
+
+ # Only apply if needed
+ # Thanks https://unix.stackexchange.com/questions/55780/check-if-a-file-or-folder-has-been-patched-already
+ for patch in `ls $BASEDIR/puppet/files/patches/$DIST`; do
+ patch -p0 -N --dry-run --silent < $BASEDIR/puppet/files/patches/$DIST/$patch &> /dev/null
+ # If the patch has not been applied then the $? which is the exit status
+ # for last command would have a success status code = 0
+ if [ "$?" == "0" ]; then
+ # Apply the patch
+ patch -p0 -N < $BASEDIR/puppet/files/patches/$DIST/$patch
+ fi
+ done
+ )
+fi
+
+# Run puppet apply
+PUPPET_OPTS="--confdir=$BASEDIR/puppet --modulepath=$BASEDIR/puppet/modules"
+LC_ALL=C $SUDO puppet apply $PUPPET_OPTS $PUPPET_MANIFEST