58 lines
1.5 KiB
Bash
58 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
configure_php() {
|
|
# 3wc: these changes allow environment variables to propagate to PHP; Selfoss
|
|
# already loads its config from environment variables but unless we make these
|
|
# changes, it can't access them. See
|
|
# https://github.com/docker-library/php/pull/93/files
|
|
if ! grep -q '^clear_env = no' /etc/php7/php-fpm.d/www.conf; then
|
|
sed -i 's/;clear_env = no/clear_env = no/' /etc/php7/php-fpm.d/www.conf
|
|
fi
|
|
if ! grep -q '^clear_env = no' /etc/php7/php-fpm.conf; then
|
|
echo 'clear_env = no' >> /etc/php7/php-fpm.conf
|
|
fi
|
|
if ! grep -q 'variables_order = "EGPCS"' /etc/php7/php.ini; then
|
|
sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/g' \
|
|
/etc/php7/php.ini
|
|
fi
|
|
}
|
|
|
|
file_env() {
|
|
# 3wc: Load $VAR_FILE into $VAR - useful for secrets. See
|
|
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
|
|
local var="$1"
|
|
local fileVar="${var}_FILE"
|
|
local def="${2:-}"
|
|
|
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
|
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
|
exit 1
|
|
fi
|
|
local val="$def"
|
|
if [ "${!var:-}" ]; then
|
|
val="${!var}"
|
|
elif [ "${!fileVar:-}" ]; then
|
|
val="$(< "${!fileVar}")"
|
|
fi
|
|
export "$var"="$val"
|
|
unset "$fileVar"
|
|
}
|
|
|
|
load_vars() {
|
|
file_env "SELFOSS_PASSWORD"
|
|
file_env "SELFOSS_DB_PASSWORD"
|
|
}
|
|
|
|
main() {
|
|
set -eu
|
|
|
|
configure_php
|
|
load_vars
|
|
}
|
|
|
|
main
|
|
|
|
# 3wc: upstream ENTRYPOINT
|
|
# https://github.com/theAkito/docker-selfoss/blob/master/Dockerfile
|
|
run.sh
|