Skip to content

Instantly share code, notes, and snippets.

@sshastri
Created August 10, 2018 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshastri/61b510b0c261d266e6e32eb7576f5abf to your computer and use it in GitHub Desktop.
Save sshastri/61b510b0c261d266e6e32eb7576f5abf to your computer and use it in GitHub Desktop.
environment.conf script
#! /bin/sh
if (( $# != 1 )); then
echo "Call this script with the name of the environment"
echo "Example: ${0} production"
exit 1
fi
CODEDIR='/etc/puppetlabs/code/environments'
CODESTAGE='/etc/puppetlabs/code-staging/environments'
GITCODEDIR="${CODEDIR}/${1}/.git"
GITCODESTAGE="${CODESTAGE}/${1}/.git"
# Are we using old-school git clones?
if [ -d ${GITCODEDIR} ]; then
git --git-dir ${GITCODEDIR} rev-parse --short HEAD
elif [ -d ${GITCODESTAGE} ]; then
git --git-dir ${GITCODESTAGE} rev-parse --short HEAD
else
date '+%s'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment