diff --git a/package/post-install.sh b/package/post-install.sh index 0a4590f5d27..05481012b97 100755 --- a/package/post-install.sh +++ b/package/post-install.sh @@ -22,19 +22,23 @@ CUSTOM_INI_FILE_NAME='ddtrace-custom.ini' PATH="${PATH}:/usr/local/bin" +function println() { + echo -e '###' "$@" +} + # We attempt in this order the following binary names: -# 1. php -# 2. php8 (some alpine versions install php 8.x from main repo to this binary) -# 3. php7 (some alpine versions install php 7.x from main repo to this binary) -# 4. php5 (some alpine versions install php 5.x from main repo to this binary) -if [ -z "$DD_TRACE_PHP_BIN" ]; then - DD_TRACE_PHP_BIN=$(command -v php || true) -fi -if [ -z "$DD_TRACE_PHP_BIN" ]; then - DD_TRACE_PHP_BIN=$(command -v php8 || true) -fi +for name in php php8 php83 php82 php81 php80 php7 php74 php73 php72 php71 php70 +do + if [ -z "$DD_TRACE_PHP_BIN" ]; then + DD_TRACE_PHP_BIN=$(command -v "$name" || true) + else + break + fi +done + if [ -z "$DD_TRACE_PHP_BIN" ]; then - DD_TRACE_PHP_BIN=$(command -v php7 || true) + println 'Unable to locate PHP binary' + exit 0 fi function invoke_php() { @@ -46,10 +50,6 @@ function invoke_php() { $DD_TRACE_PHP_BIN -d memory_limit=128M "$*" } -function println() { - echo -e '###' "$@" -} - function append_configuration_to_file() { tee -a "$@" <