From 8b2055b05480a5a1b539b0e73893030c58411dec Mon Sep 17 00:00:00 2001 From: Chris Barton Date: Wed, 4 Apr 2018 14:47:30 +0930 Subject: [PATCH 1/2] Make the setup_xdebug method a bit smarter by actually getting the php version, not a hardcoded string that breaks when versions are updated in your image(s). --- dsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dsh b/dsh index 57895e0..ec733f4 100755 --- a/dsh +++ b/dsh @@ -288,7 +288,9 @@ dsh_setup_dnsmasq() { setup_xdebug() { HOST_IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1) notice "Configuring xdebug to connect to host at: ${HOST_IP}." - docker exec -t "${PROJECT}_web_1" sed -i "s/^xdebug\.remote_host=.*$/xdebug.remote_host=${HOST_IP}/" /etc/php/7.1/mods-available/xdebug.ini + # Get the PHP VERSION, so we edit the correct ini file. + PHP_VERSION=$(php -v | head -n1 | awk '{print $2}' | awk -F '-' '{print $1}' | awk -F '.' '{print $1"."$2}') + docker exec -t "${PROJECT}_web_1" sed -i "s/^xdebug\.remote_host=.*$/xdebug.remote_host=${HOST_IP}/" "/etc/php/${PHP_VERSION}/mods-available/xdebug.ini" set +e docker exec -t -u root "${PROJECT}_web_1" apachectl graceful 2> /dev/null set -e From c32e57d64da4ac3c60f648c0307eee2104de51e5 Mon Sep 17 00:00:00 2001 From: Chris Barton Date: Wed, 4 Apr 2018 15:24:04 +0930 Subject: [PATCH 2/2] Woo many awk | that --- dsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsh b/dsh index ec733f4..77682f3 100755 --- a/dsh +++ b/dsh @@ -289,7 +289,7 @@ setup_xdebug() { HOST_IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1) notice "Configuring xdebug to connect to host at: ${HOST_IP}." # Get the PHP VERSION, so we edit the correct ini file. - PHP_VERSION=$(php -v | head -n1 | awk '{print $2}' | awk -F '-' '{print $1}' | awk -F '.' '{print $1"."$2}') + PHP_VERSION=$(docker exec -t "${PROJECT}_web_1" php -v | head -n1 | awk '{print $2}' | awk -F '-' '{print $1}' | awk -F '.' '{print $1"."$2}') docker exec -t "${PROJECT}_web_1" sed -i "s/^xdebug\.remote_host=.*$/xdebug.remote_host=${HOST_IP}/" "/etc/php/${PHP_VERSION}/mods-available/xdebug.ini" set +e docker exec -t -u root "${PROJECT}_web_1" apachectl graceful 2> /dev/null