Skip to content

Commit

Permalink
Fix PHP binary detection in package post-install script (#2707)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamluc authored Jun 11, 2024
1 parent c9065c5 commit 4bbc100
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions package/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 "$@" <<EOF
; Autogenerated by the Datadog post-install.sh script
Expand Down

0 comments on commit 4bbc100

Please sign in to comment.