11#! /bin/sh
22
3+ ENVIRONMENTPATH=$1
4+ # $ENVIRONMENTPATH may contain multiple colon-delimited locations.
5+ # We need to pick the first one that contains $ENVIRONMENT.
6+ IFS=" :"
7+ for CANDIDATEPATH in ${ENVIRONMENTPATH} ; do
8+ if [ -d " ${CANDIDATEPATH} /${2} " ]; then
9+ ENVIRONMENTPATH=$CANDIDATEPATH
10+ break
11+ fi
12+ done
13+
314# Usage
4- if [ $# -ne 2 -o ! -d " $1 " -o ! -d " $1 /$2 " ]; then
15+ if [ $# -ne 2 -o ! -d " ${ENVIRONMENTPATH} " -o ! -d " ${ENVIRONMENTPATH} /$2 " ]; then
516 echo " usage: $0 <environmentpath> <environment>" >&2
617 exit 1
718fi
@@ -14,19 +25,19 @@ ruby() {
1425}
1526
1627# Determine how best to calculate a config_version
17- if [ -e $1 /$2 /.r10k-deploy.json ]; then
28+ if [ -e ${ENVIRONMENTPATH} /$2 /.r10k-deploy.json ]; then
1829 # The environment was deployed using r10k. We will calculate the config
1930 # version using the r10k data.
20- ruby $1 /$2 /scripts/config_version-r10k.rb $1 $2
31+ ruby ${ENVIRONMENTPATH} /$2 /scripts/config_version-r10k.rb $1 $2
2132
2233elif [ -e /opt/puppetlabs/server/pe_version ]; then
2334 # This is a Puppet Enterprise system and we can rely on the rugged ruby gem
2435 # being available.
25- ruby $1 /$2 /scripts/config_version-rugged.rb $1 $2
36+ ruby ${ENVIRONMENTPATH} /$2 /scripts/config_version-rugged.rb $1 $2
2637
2738elif type git > /dev/null; then
2839 # The git command is available.
29- git --git-dir $1 /$2 /.git rev-parse HEAD
40+ git --git-dir ${ENVIRONMENTPATH} /$2 /.git rev-parse HEAD
3041
3142else
3243 # Nothing else available; just use the date.
0 commit comments