11-clear-env.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Workaround for old php-fpm versions which don't have clear_env setting
  3. #
  4. VARIABLE_LIST="; Workaround for missing clear_env feature in PHP-FPM"
  5. # For each exported variable
  6. for envVariable in $(printenv|cut -f1 -d=); do
  7. case "$envVariable" in
  8. "_"|"PATH"|"PWD")
  9. ## ignore this variables
  10. ;;
  11. *)
  12. ## get content of variable
  13. envVariableContent="${!envVariable}"
  14. ## php-fpm requires that env variable has to be filled with content
  15. if [[ -n "$envVariableContent" ]]; then
  16. ## quote quotes
  17. envVariableContent=${envVariableContent//\"/\\\"}
  18. ## add to list
  19. VARIABLE_LIST="${VARIABLE_LIST}"$'\n'"env[${envVariable}] = \"${envVariableContent}\""
  20. fi
  21. ;;
  22. esac
  23. done
  24. # Replace ;#CLEAR_ENV_WORKAROUND# with environment variable list for all php-fpm pool files
  25. go-replace \
  26. -s ";#CLEAR_ENV_WORKAROUND#" -r "$VARIABLE_LIST" \
  27. --path=/opt/docker/etc/php/fpm/pool.d/ \
  28. --path-pattern='*.conf' \
  29. --ignore-empty