Skip to content

Commit 4bbc100

Browse files
authored
Fix PHP binary detection in package post-install script (#2707)
1 parent c9065c5 commit 4bbc100

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

package/post-install.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ CUSTOM_INI_FILE_NAME='ddtrace-custom.ini'
2222

2323
PATH="${PATH}:/usr/local/bin"
2424

25+
function println() {
26+
echo -e '###' "$@"
27+
}
28+
2529
# We attempt in this order the following binary names:
26-
# 1. php
27-
# 2. php8 (some alpine versions install php 8.x from main repo to this binary)
28-
# 3. php7 (some alpine versions install php 7.x from main repo to this binary)
29-
# 4. php5 (some alpine versions install php 5.x from main repo to this binary)
30-
if [ -z "$DD_TRACE_PHP_BIN" ]; then
31-
DD_TRACE_PHP_BIN=$(command -v php || true)
32-
fi
33-
if [ -z "$DD_TRACE_PHP_BIN" ]; then
34-
DD_TRACE_PHP_BIN=$(command -v php8 || true)
35-
fi
30+
for name in php php8 php83 php82 php81 php80 php7 php74 php73 php72 php71 php70
31+
do
32+
if [ -z "$DD_TRACE_PHP_BIN" ]; then
33+
DD_TRACE_PHP_BIN=$(command -v "$name" || true)
34+
else
35+
break
36+
fi
37+
done
38+
3639
if [ -z "$DD_TRACE_PHP_BIN" ]; then
37-
DD_TRACE_PHP_BIN=$(command -v php7 || true)
40+
println 'Unable to locate PHP binary'
41+
exit 0
3842
fi
3943

4044
function invoke_php() {
@@ -46,10 +50,6 @@ function invoke_php() {
4650
$DD_TRACE_PHP_BIN -d memory_limit=128M "$*"
4751
}
4852

49-
function println() {
50-
echo -e '###' "$@"
51-
}
52-
5353
function append_configuration_to_file() {
5454
tee -a "$@" <<EOF
5555
; Autogenerated by the Datadog post-install.sh script

0 commit comments

Comments
 (0)