Skip to content

Commit ffc1769

Browse files
committed
Improve portability
- Fix shebang: `bash` is not always in `/bin/`, and since the script does not have bashism, rely on `sh` which is always in `/bin/`; - Use `/opt/puppetlabs/puppet/bin/ruby` if this file exist and is executable, otherwise use `ruby` from $PATH; - Use `code_manager_config_version.rb` if `.r10k-deploy.json` is found, and `config_version.rb` in all other cases.
1 parent f69ffd8 commit ffc1769

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

scripts/config_version.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
#!/bin/bash
2-
if [ -e $1/$2/.r10k-deploy.json ]
3-
then
4-
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
5-
elif [ -e /opt/puppetlabs/server/pe_version ]
6-
then
7-
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
8-
else
9-
/usr/bin/git --version > /dev/null 2>&1 &&
10-
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
11-
date +%s
1+
#!/bin/sh
2+
3+
ruby=ruby
4+
script="$1/$2/scripts/config_version.rb"
5+
6+
if [ -x /opt/puppetlabs/puppet/bin/ruby ]; then
7+
ruby=/opt/puppetlabs/puppet/bin/ruby
128
fi
9+
10+
if [ -e $1/$2/.r10k-deploy.json ]; then
11+
script="$1/$2/scripts/code_manager_config_version.rb"
12+
fi
13+
14+
"${ruby}" "${script}" "$1" "$2"

0 commit comments

Comments
 (0)