#!/usr/bin/env sh set -eu # Properly detect requested redirect if [ "${REDIRECT_PROTO}" == "auto" ]; then REDIRECT_PROTO="\$http_x_forwarded_proto"; elif [ "${REDIRECT_PROTO}" != "http" ] && [ "${REDIRECT_PROTO}" != "https" ]; then echo "ERROR: Invalid value for REDIRECT_PROTO, got '${REDIRECT_PROTO}'" >&2 echo "ERROR: Valid values are: 'auto', 'http' or 'https'" >&2 exit 1 fi # Replace templates in nginx config for file in /etc/nginx/*/*.tpl; do sed \ -e "s#{{DOCUMENT_ROOT}}#${DOCUMENT_ROOT}#g" \ -e "s#{{REDIRECT_CODE}}#${REDIRECT_CODE}#g" \ -e "s#{{REDIRECT_PROTO}}#${REDIRECT_PROTO}#g" \ "${file}" \ > "${file%.tpl}" done # Activate the right rm -f /etc/nginx/sites-enabled/redirect-*.conf if [[ -f "/etc/nginx/sites-available/redirect-${REDIRECT_MODE}.conf" ]]; then ln -s \ "/etc/nginx/sites-available/redirect-${REDIRECT_MODE}.conf" \ "/etc/nginx/sites-enabled/redirect-${REDIRECT_MODE}.conf" fi # Configure or disable XDebug as requested XDEBUG_INI="/usr/local/etc/php/conf.d/10-xdebug.ini" if [ ${XDEBUG} = true ] || [ "${XDEBUG}" == "1" ]; then for setting in $(env | egrep '^XDEBUG_'); do key=$(echo "${setting}" | cut -d'=' -f1 | sed -e 's/XDEBUG_/xdebug./' | tr 'A-Z' 'a-z') value=$(echo "${setting}" | cut -d'=' -f2-) echo "${key}=${value}" >> "${XDEBUG_INI}" done else rm -f "${XDEBUG_INI}" fi if [ "${ENV_WHITELIST}" == "all" ]; then rm -rf /usr/local/etc/php-fpm.d/50-clear-env.conf elif [ "${ENV_WHITELIST}" != "none" ]; then echo "ERROR: Invalid value for ENV_WHITELIST, got '${ENV_WHITELIST}'" >&2 echo "ERROR: Valid values are: 'none' or 'all'" >&2 exit 1 fi exec /usr/bin/supervisord -c /etc/supervisord.conf