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.
This commit is contained in:
Romain Tartière 2018-04-07 11:13:41 +02:00
parent f69ffd8ce1
commit ffc1769d2e

View File

@ -1,12 +1,14 @@
#!/bin/bash #!/bin/sh
if [ -e $1/$2/.r10k-deploy.json ]
then ruby=ruby
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2 script="$1/$2/scripts/config_version.rb"
elif [ -e /opt/puppetlabs/server/pe_version ]
then if [ -x /opt/puppetlabs/puppet/bin/ruby ]; then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2 ruby=/opt/puppetlabs/puppet/bin/ruby
else
/usr/bin/git --version > /dev/null 2>&1 &&
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
date +%s
fi fi
if [ -e $1/$2/.r10k-deploy.json ]; then
script="$1/$2/scripts/code_manager_config_version.rb"
fi
"${ruby}" "${script}" "$1" "$2"