prepare.sh 1.5 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. echo "[PREPARE] docker/server/prepare.sh'"
  3. # Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh'
  4. source "docker/attributes.sh"
  5. # This condition creates the Unix socket if 'php-fpm8.sock' does not already exist.
  6. # This fixes an issue where Nginx starts but does not serve content
  7. if [ ! -d "/run/php8" ] || [ ! -S "/run/php8/php-fpm8.sock" ]; then
  8. mkdir "/run/php8"
  9. touch "/run/php8/php-fpm8.sock"
  10. chmod 660 "/run/php8/php-fpm8.sock"
  11. chown nginx:nginx "/run/php8/php-fpm8.sock"
  12. fi
  13. # The lines below will replace the environment variables in the templates with the corresponding variables listed above. To accomplish this, the GNU 'envsubst' package will be used
  14. # Although not recommended (if you do not know what you are doing), you still have the option to add new substitution file templates using any required environment variables
  15. [[ ! -s ${CONFIG_PHP_TEMPLATE} ]] && cat 'docker/php/config.php' | envsubst > ${CONFIG_PHP_TEMPLATE};
  16. [[ ! -s ${CONFIG_OPEN_SEARCH_TEMPLATE} ]] && cat 'docker/php/opensearch.xml' | envsubst > ${CONFIG_OPEN_SEARCH_TEMPLATE};
  17. # If it is empty or proxy is not enabled, we are using sed to delete
  18. # any line that contains the string 'CURLOPT_PROXY' or 'CURLOPT_PROXYTYPE'
  19. # from the file 'config.php' defined on top of 'attributes.sh'
  20. if [[ -z "${CURLOPT_PROXY}" || "${CURLOPT_PROXY_ENABLED}" = false ]]; then
  21. sed -i "/CURLOPT_PROXY/d" ${CONFIG_PHP_TEMPLATE};
  22. sed -i "/CURLOPT_PROXYTYPE/d" ${CONFIG_PHP_TEMPLATE};
  23. fi