* use helpers script with dot version function for xdebug start and quit script
* condionaly laynch sed tunr on profile options for php 74 & correct appropriate logic
This commit is contained in:
5
bash/_helpers.sh
Normal file
5
bash/_helpers.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
function dot_version() {
|
||||||
|
sed -r 's/^([[:digit:]])/\1./g' <<< $1
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f dot_version
|
@ -1,29 +1,43 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Not working on windows symlinks
|
SCRIPT_DIR="$(realpath $(dirname "$(readlink -f "$0")"))"
|
||||||
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
|
|
||||||
|
|
||||||
PHP_VERSION=$1 # Without dot
|
set -e
|
||||||
|
|
||||||
|
. $SCRIPT_DIR/_helpers.sh || {
|
||||||
|
echo "no helpers" && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR/.."
|
||||||
|
|
||||||
|
PHP_VERSION=$1
|
||||||
|
|
||||||
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
|
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
|
||||||
|
|
||||||
|
WITH_PROFILER=$2
|
||||||
|
|
||||||
|
PHP_DOT_VERSION=$(dot_version ${PHP_VERSION})
|
||||||
|
|
||||||
PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
|
PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
|
||||||
WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
|
WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
|
||||||
|
|
||||||
PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||||
WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini
|
WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/20-xdebug.ini
|
||||||
|
|
||||||
|
PHP_FPM_XDEBUG_CONFIG_PATH=/usr/local/etc/php/conf.d/xdebug.ini
|
||||||
|
WORKSPACE_XDEBUG_CONFIG_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/xdebug.ini
|
||||||
|
|
||||||
SED_XDEBUG_ON="sed -i 's/^zend_extension=/;zend_extension=/g'"
|
SED_XDEBUG_ON="sed -i 's/^zend_extension=/;zend_extension=/g'"
|
||||||
|
|
||||||
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
||||||
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
||||||
|
|
||||||
echo "Choice PHP_VERSION: $PHP_VERSION"
|
echo "Xdebug off: $PHP_VERSION"
|
||||||
|
|
||||||
if [ "${PHP_VERSION}" -ne 74 ]; then
|
if [ "${PHP_VERSION}" = 74 ]; then
|
||||||
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=0/g'"
|
SED_PROFILER_OFF="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=0/g'"
|
||||||
else
|
else
|
||||||
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=off/g'"
|
SED_PROFILER_OFF="sed -i 's/^xdebug.mode=.*/xdebug.mode=off/g'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_PROFILER_OFF} ${PHP_FPM_XDEBUG_CONFIG_PATH}"
|
||||||
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_PROFILER_OFF} ${WORKSPACE_XDEBUG_CONFIG_PATH}"
|
||||||
|
@ -1,36 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Not working on windows symlinks
|
# Line above doe not correctly work for this script symlinks
|
||||||
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
|
#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
# And symlinks are not working on windows.
|
||||||
|
SCRIPT_DIR="$(realpath $(dirname "$(readlink -f "$0")"))"
|
||||||
|
|
||||||
PHP_VERSION=$1 # Without dot
|
set -e
|
||||||
WITH_PROFILER=$2
|
|
||||||
|
. $SCRIPT_DIR/_helpers.sh || {
|
||||||
|
echo "no helpers" && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR/.."
|
||||||
|
|
||||||
|
PHP_VERSION=$1
|
||||||
|
|
||||||
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
|
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
|
||||||
|
|
||||||
|
WITH_PROFILER=$2
|
||||||
|
|
||||||
|
PHP_DOT_VERSION=$(dot_version ${PHP_VERSION})
|
||||||
|
|
||||||
PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
|
PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
|
||||||
WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
|
WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
|
||||||
|
|
||||||
PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||||
WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini
|
WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/20-xdebug.ini
|
||||||
|
|
||||||
|
PHP_FPM_XDEBUG_CONFIG_PATH=/usr/local/etc/php/conf.d/xdebug.ini
|
||||||
|
WORKSPACE_XDEBUG_CONFIG_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/xdebug.ini
|
||||||
|
|
||||||
SED_XDEBUG_ON="sed -i 's/^;zend_extension=/zend_extension=/g'"
|
SED_XDEBUG_ON="sed -i 's/^;zend_extension=/zend_extension=/g'"
|
||||||
|
|
||||||
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
||||||
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
||||||
|
|
||||||
echo "Choice PHP_VERSION: $PHP_VERSION"
|
echo "Turn on xdebug: $PHP_VERSION"
|
||||||
|
|
||||||
if [ "${PHP_VERSION}" -ne 74 ]; then
|
if [ -n "${WITH_PROFILER}" ]; then
|
||||||
if [ -n "${WITH_PROFILER}" ]; then
|
echo "Profiler enabled"
|
||||||
|
if [ "${PHP_VERSION}" = 74 ]; then
|
||||||
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=1/g'"
|
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=1/g'"
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -n "${WITH_PROFILER}" ]; then
|
|
||||||
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=profile/g'"
|
|
||||||
else
|
else
|
||||||
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=debug/g'"
|
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=profile/g'"
|
||||||
fi
|
fi
|
||||||
|
elif [ "${PHP_VERSION}" -ne 74 ]; then
|
||||||
|
SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=debug/g'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
|
if [ -n "${SED_DEBUG_OR_PROFILER_MODE_ON}" ]; then
|
||||||
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
|
docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${PHP_FPM_XDEBUG_CONFIG_PATH}"
|
||||||
|
docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${WORKSPACE_XDEBUG_CONFIG_PATH}"
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user