Skip to content

Commit

Permalink
Handle colon-delimited environmentpath in config_version.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaynton committed Nov 16, 2019
1 parent 78662f9 commit 0cd1e1b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions scripts/config_version.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
#!/bin/bash
if [ -e $1/$2/.r10k-deploy.json ]
ENVIRONMENTPATH=$1
# $ENVIRONMENTPATH may contain multiple colon-delimited locations.
# We need to pick the first one that contains $ENVIRONMENT.
IFS=":"
for CANDIDATEPATH in ${ENVIRONMENTPATH}; do
if [ -d "${CANDIDATEPATH}/${2}" ]; then
ENVIRONMENTPATH=$CANDIDATEPATH
break
fi
done

if [ -e "${ENVIRONMENTPATH}/$2/.r10k-deploy.json" ]
then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
/opt/puppetlabs/puppet/bin/ruby "${ENVIRONMENTPATH}/$2/scripts/code_manager_config_version.rb" ${ENVIRONMENTPATH} $2
elif [ -e /opt/puppetlabs/server/pe_version ]
then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
/opt/puppetlabs/puppet/bin/ruby "${ENVIRONMENTPATH}/$2/scripts/config_version.rb" ${ENVIRONMENTPATH} $2
else
/usr/bin/git --version > /dev/null 2>&1 &&
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
/usr/bin/git --git-dir "${ENVIRONMENTPATH}/$2/.git" rev-parse HEAD ||
date +%s
fi

0 comments on commit 0cd1e1b

Please sign in to comment.