2023-02-11 18:08:53 -08:00
#!/bin/sh
2023-02-12 08:35:16 -08:00
echo "[PREPARE] docker/server/prepare.sh'"
2023-02-11 18:08:53 -08:00
# Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh'
source "docker/attributes.sh"
2023-06-23 06:51:40 -07:00
# This condition creates the Unix socket if 'php-fpm8.sock' does not already exist.
2023-02-12 09:34:38 -08:00
# This fixes an issue where Nginx starts but does not serve content
2023-06-23 06:51:40 -07:00
if [ ! -d "/run/php8" ] || [ ! -S "/run/php8/php-fpm8.sock" ] ; then
mkdir "/run/php8"
touch "/run/php8/php-fpm8.sock"
chmod 660 "/run/php8/php-fpm8.sock"
chown nginx:nginx "/run/php8/php-fpm8.sock"
2023-02-12 09:34:38 -08:00
fi
2023-02-11 18:08:53 -08:00
# 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
# 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
2023-02-12 06:13:58 -08:00
[ [ ! -s ${ CONFIG_PHP_TEMPLATE } ] ] && cat 'docker/php/config.php' | envsubst > ${ CONFIG_PHP_TEMPLATE } ;
[ [ ! -s ${ CONFIG_OPEN_SEARCH_TEMPLATE } ] ] && cat 'docker/php/opensearch.xml' | envsubst > ${ CONFIG_OPEN_SEARCH_TEMPLATE } ;
2023-02-11 18:32:45 -08:00
# If it is empty or proxy is not enabled, we are using sed to delete
# any line that contains the string 'CURLOPT_PROXY' or 'CURLOPT_PROXYTYPE'
# from the file 'config.php' defined on top of 'attributes.sh'
if [ [ -z " ${ CURLOPT_PROXY } " || " ${ CURLOPT_PROXY_ENABLED } " = false ] ] ; then
sed -i "/CURLOPT_PROXY/d" ${ CONFIG_PHP_TEMPLATE } ;
sed -i "/CURLOPT_PROXYTYPE/d" ${ CONFIG_PHP_TEMPLATE } ;
fi