Skip to content

Commit 6667702

Browse files
fix(php): fixed php recipe to accommodate recent php agent changes
1 parent 56937e6 commit 6667702

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

recipes/newrelic/apm/php/debian.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,20 @@ install:
465465
# Get the PHP INI Directory associated with this specific NR INI file
466466
#
467467
php_ini_dir=$(echo $ini | sed -n 's/\(.*\)\/conf.d/\1/p')
468-
if [ -z "${php_ini_dir}" ]; then
469-
php_ini_dir=$ini
468+
if [[ -z "${php_ini_dir}" ]]; then
469+
if [[ -z "${CLI_DIRS}" ]]; then
470+
if [[ -d "${ini}/../apache2" ]]; then
471+
php_ini_dir="${ini}/../apache2"
472+
fi
473+
if [[ -d "${ini}/../fpm" ]]; then
474+
php_ini_dir="${ini}/../fpm"
475+
fi
476+
elif [[ -d "${ini}/../cli" ]]; then
477+
php_ini_dir="${ini}/../cli"
478+
else
479+
php_ini_dir=$ini
480+
fi
470481
fi
471-
472482
#
473483
# Get the PHP Binary directory associated with this particular NR INI file.
474484
sed_slash_ini=$(echo "${ini}" | sed 's/\//\\\//g')
@@ -501,6 +511,10 @@ install:
501511
fi
502512
503513
sed -i "s/newrelic.appname = \"[^\"]*\"/newrelic.appname = \"${APPLICATION_NAME}\"/" $ini_full_name
514+
515+
LICENSE_KEY="{{.NEW_RELIC_LICENSE_KEY}}"
516+
sed -i -E "s/newrelic.license = \"(REPLACE_WITH_REAL_KEY|)\"/newrelic.license = \"${NEW_RELIC_LICENSE_KEY}\"/" $ini_full_name
517+
504518
if [ "{{.NEW_RELIC_REGION}}" = "STAGING" ]; then
505519
sed -i 's/;newrelic.daemon.collector_host = ""/newrelic.daemon.collector_host = "staging-collector.newrelic.com"/' $ini_full_name
506520
sed -i 's/;newrelic.loglevel = "info"/newrelic.loglevel = "verbosedebug"/' $ini_full_name
@@ -520,7 +534,7 @@ install:
520534
#
521535
target_ini_dir="/etc/php5/conf.d/"
522536
if [ -x /usr/sbin/phpquery ]; then
523-
target_ini_dir="${ini}/../../mods-available/"
537+
target_ini_dir="${php_ini_dir}/../mods-available/"
524538
elif [ -x /usr/sbin/php5endmod ]; then
525539
target_ini_dir="/etc/php5/mods-available/"
526540
fi
@@ -533,7 +547,11 @@ install:
533547
# This ensures we always get the most up to date newrelic.ini file on the
534548
# system.
535549
#
536-
mv ${ini_full_name} ${target_ini_dir}
550+
ini_source_dir=$(dirname "$(realpath "$ini_full_name")")
551+
ini_destination_dir=$(realpath "$target_ini_dir")
552+
if [[ "$ini_source_dir" != "$ini_destination_dir" ]]; then
553+
mv "${ini_full_name}" "${ini_destination_dir}"
554+
fi
537555
538556
#
539557
# We rely on the package installer to enable the newrelic module.

0 commit comments

Comments
 (0)