You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. #!/bin/bash
  2. SCRIPT_DIR="$(realpath $(dirname "$(readlink -f "$0")"))"
  3. set -e
  4. . $SCRIPT_DIR/_helpers.sh || {
  5. echo "no helpers" && exit 1
  6. }
  7. cd "$SCRIPT_DIR/.."
  8. PHP_VERSION=$1
  9. if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
  10. WITH_PROFILER=$2
  11. PHP_DOT_VERSION=$(dot_version ${PHP_VERSION})
  12. PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
  13. WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
  14. PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
  15. WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/20-xdebug.ini
  16. PHP_FPM_XDEBUG_CONFIG_PATH=/usr/local/etc/php/conf.d/xdebug.ini
  17. WORKSPACE_XDEBUG_CONFIG_PATH=/etc/php/${PHP_DOT_VERSION}/cli/conf.d/xdebug.ini
  18. SED_XDEBUG_ON="sed -i 's/^zend_extension=/;zend_extension=/g'"
  19. docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
  20. docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
  21. echo "Xdebug off: $PHP_VERSION"
  22. if [ "${PHP_VERSION}" = 74 ]; then
  23. SED_PROFILER_OFF="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=0/g'"
  24. else
  25. SED_PROFILER_OFF="sed -i 's/^xdebug.mode=.*/xdebug.mode=off/g'"
  26. fi
  27. docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_PROFILER_OFF} ${PHP_FPM_XDEBUG_CONFIG_PATH}"
  28. docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_PROFILER_OFF} ${WORKSPACE_XDEBUG_CONFIG_PATH}"
  29. docker restart "${PHP_FPM_CONTAINER}"