1
1
#! /bin/sh
2
2
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
+
3
14
# 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
5
16
echo " usage: $0 <environmentpath> <environment>" >&2
6
17
exit 1
7
18
fi
@@ -14,19 +25,19 @@ ruby() {
14
25
}
15
26
16
27
# 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
18
29
# The environment was deployed using r10k. We will calculate the config
19
30
# 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
21
32
22
33
elif [ -e /opt/puppetlabs/server/pe_version ]; then
23
34
# This is a Puppet Enterprise system and we can rely on the rugged ruby gem
24
35
# being available.
25
- ruby $1 /$2 /scripts/config_version-rugged.rb $1 $2
36
+ ruby ${ENVIRONMENTPATH} /$2 /scripts/config_version-rugged.rb $1 $2
26
37
27
38
elif type git > /dev/null; then
28
39
# 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
30
41
31
42
else
32
43
# Nothing else available; just use the date.
0 commit comments