git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormail_redacted_for_web 2018-04-07 11:13:41 +0200
committermail_redacted_for_web 2018-05-11 22:25:27 +0200
commitffc1769d2e9ab6057d44660e2ef4430a70652836 (patch)
treee25e91b8dfb19703bd8d113570e3f48d2cb85ed1
parentf69ffd8ce1a995892c7bca84d8c67e0c1a39a47e (diff)
downloadcontrol-repo-template-ffc1769d2e9ab6057d44660e2ef4430a70652836.tar.bz2
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.
-rwxr-xr-xscripts/config_version.sh24
1 files changed, 13 insertions, 11 deletions
diff --git a/scripts/config_version.sh b/scripts/config_version.sh
index 8dd8086..0378952 100755
--- a/scripts/config_version.sh
+++ b/scripts/config_version.sh
@@ -1,12 +1,14 @@
-#!/bin/bash
-if [ -e $1/$2/.r10k-deploy.json ]
-then
- /opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
-elif [ -e /opt/puppetlabs/server/pe_version ]
-then
- /opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
-else
- /usr/bin/git --version > /dev/null 2>&1 &&
- /usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
- date +%s
+#!/bin/sh
+
+ruby=ruby
+script="$1/$2/scripts/config_version.rb"
+
+if [ -x /opt/puppetlabs/puppet/bin/ruby ]; then
+ ruby=/opt/puppetlabs/puppet/bin/ruby
fi
+
+if [ -e $1/$2/.r10k-deploy.json ]; then
+ script="$1/$2/scripts/code_manager_config_version.rb"
+fi
+
+"${ruby}" "${script}" "$1" "$2"