From: Thomas Bruederli Date: Sat, 26 Dec 2020 20:38:15 +0000 (+0100) Subject: Write individual config file from env vars X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=8ab3f5cad9cf9d611e48a3daa11278d111dc296b;p=roundcube-roundcubemail-docker.git Write individual config file from env vars This implements the changes proposed in #112 in order to reflect (changed) env vars used with the Docker container. --- diff --git a/templates/docker-entrypoint.sh b/templates/docker-entrypoint.sh index 68df92c..83758b8 100644 --- a/templates/docker-entrypoint.sh +++ b/templates/docker-entrypoint.sh @@ -72,37 +72,49 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}" if [ ! -e config/config.inc.php ]; then - ROUNDCUBEMAIL_PLUGINS_PHP=`echo "${ROUNDCUBEMAIL_PLUGINS}" | sed -E "s/[, ]+/', '/g"` - ROUNDCUBEMAIL_DES_KEY=`test -f /run/secrets/roundcube_des_key && cat /run/secrets/roundcube_des_key || head /dev/urandom | base64 | head -c 24` + ROUNDCUBEMAIL_DES_KEY=`head /dev/urandom | base64 | head -c 24` touch config/config.inc.php - echo "Write config to $PWD/config/config.inc.php" + echo "Write root config to $PWD/config/config.inc.php" echo " config/config.inc.php - for fn in `ls /var/roundcube/config/*.php 2>/dev/null || true`; do - echo "include('$fn');" >> config/config.inc.php - done + elif ! grep -q "config.docker.inc.php" config/config.inc.php; then + echo "include(__DIR__ . '/config.docker.inc.php');" >> config/config.inc.php + fi - # initialize or update DB - bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." - else - echo "WARNING: $PWD/config/config.inc.php already exists." - echo "ROUNDCUBEMAIL_* environment variables have been ignored." + ROUNDCUBEMAIL_PLUGINS_PHP=`echo "${ROUNDCUBEMAIL_PLUGINS}" | sed -E "s/[, ]+/', '/g"` + echo "Write Docker config to $PWD/config/config.docker.inc.php" + echo " config/config.docker.inc.php + + if [ -e /run/secrets/roundcube_des_key ]; then + ROUNDCUBEMAIL_DES_KEY=`cat /run/secrets/roundcube_des_key` + echo "\$config['des_key'] = '${ROUNDCUBEMAIL_DES_KEY}';" >> config/config.docker.inc.php fi + # include custom config files + for fn in `ls /var/roundcube/config/*.php 2>/dev/null || true`; do + echo "include('$fn');" >> config/config.docker.inc.php + done + + # initialize or update DB + bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR} fi @@ -114,7 +126,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then : "${ROUNDCUBEMAIL_LOCALE:=en_US.UTF-8 UTF-8}" - if [ ! -z "${ROUNDCUBEMAIL_LOCALE}" ]; then + if [ -e /usr/sbin/locale-gen ] && [ ! -z "${ROUNDCUBEMAIL_LOCALE}" ]; then echo "${ROUNDCUBEMAIL_LOCALE}" > /etc/locale.gen /usr/sbin/locale-gen fi