2017-03-28 17:46:14 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -eu
|
|
|
|
|
2017-03-29 17:23:29 +00:00
|
|
|
# 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
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2017-03-29 17:23:29 +00:00
|
|
|
# Replace templates in nginx config
|
|
|
|
for file in /etc/nginx/*/*.tpl; do
|
|
|
|
sed \
|
2017-03-28 17:46:14 +00:00
|
|
|
-e "s#{{DOCUMENT_ROOT}}#${DOCUMENT_ROOT}#g" \
|
2017-03-29 17:23:29 +00:00
|
|
|
-e "s#{{REDIRECT_CODE}}#${REDIRECT_CODE}#g" \
|
|
|
|
-e "s#{{REDIRECT_PROTO}}#${REDIRECT_PROTO}#g" \
|
|
|
|
"${file}" \
|
|
|
|
> "${file%.tpl}"
|
2017-03-28 17:46:14 +00:00
|
|
|
done
|
|
|
|
|
2017-03-29 17:23:29 +00:00
|
|
|
# Activate the right
|
2017-03-28 19:28:56 +00:00
|
|
|
rm -f /etc/nginx/sites-enabled/redirect-*.conf
|
2017-03-29 17:23:29 +00:00
|
|
|
if [[ -f "/etc/nginx/sites-available/redirect-${REDIRECT_MODE}.conf" ]]; then
|
2017-03-28 17:46:14 +00:00
|
|
|
ln -s \
|
2017-03-29 17:23:29 +00:00
|
|
|
"/etc/nginx/sites-available/redirect-${REDIRECT_MODE}.conf" \
|
|
|
|
"/etc/nginx/sites-enabled/redirect-${REDIRECT_MODE}.conf"
|
2017-03-28 17:46:14 +00:00
|
|
|
fi
|
|
|
|
|
2017-04-26 15:16:56 +00:00
|
|
|
# Configure or disable XDebug as requested
|
|
|
|
XDEBUG_INI="/usr/local/etc/php/conf.d/10-xdebug.ini"
|
|
|
|
if [ ${XDEBUG} = true ] || [ "${XDEBUG}" == "1" ]; then
|
|
|
|
env \
|
|
|
|
| egrep '^XDEBUG_' \
|
|
|
|
| sed -e 's/XDEBUG_/xdebug./' \
|
|
|
|
| tr 'A-Z' 'a-z' \
|
|
|
|
>> "${XDEBUG_INI}"
|
|
|
|
else
|
|
|
|
rm -f "${XDEBUG_INI}"
|
|
|
|
fi
|
|
|
|
|
2017-03-29 17:23:29 +00:00
|
|
|
exec /usr/bin/supervisord -c /etc/supervisord.conf
|