From 4f8e8306f82846d255c69993c63d145344385a32 Mon Sep 17 00:00:00 2001 From: Jarrod Lowe <41766555+jarrod-lowe@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:16:50 +1300 Subject: [PATCH] Bootstrap config.php Allow the docker, kubernetes, etc, environment to provide a config.php that sets values prior to setup. Signed-off-by: Jarrod Lowe Bootstrap config.php documentation Signed-off-by: Jarrod Lowe Note when copy happens ... on install only Signed-off-by: Jarrod Lowe Undo whitespace change Update per-version entrypoint files --- 16.0/apache/entrypoint.sh | 4 ++++ 16.0/fpm-alpine/entrypoint.sh | 4 ++++ 16.0/fpm/entrypoint.sh | 4 ++++ 17.0/apache/entrypoint.sh | 4 ++++ 17.0/fpm-alpine/entrypoint.sh | 4 ++++ 17.0/fpm/entrypoint.sh | 4 ++++ 18.0/apache/entrypoint.sh | 4 ++++ 18.0/fpm-alpine/entrypoint.sh | 4 ++++ 18.0/fpm/entrypoint.sh | 4 ++++ README.md | 2 ++ docker-entrypoint.sh | 4 ++++ 11 files changed, 42 insertions(+) diff --git a/16.0/apache/entrypoint.sh b/16.0/apache/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/16.0/apache/entrypoint.sh +++ b/16.0/apache/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/16.0/fpm-alpine/entrypoint.sh b/16.0/fpm-alpine/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/16.0/fpm-alpine/entrypoint.sh +++ b/16.0/fpm-alpine/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/16.0/fpm/entrypoint.sh b/16.0/fpm/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/16.0/fpm/entrypoint.sh +++ b/16.0/fpm/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/17.0/apache/entrypoint.sh b/17.0/apache/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/17.0/apache/entrypoint.sh +++ b/17.0/apache/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/17.0/fpm-alpine/entrypoint.sh b/17.0/fpm-alpine/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/17.0/fpm-alpine/entrypoint.sh +++ b/17.0/fpm-alpine/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/17.0/fpm/entrypoint.sh b/17.0/fpm/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/17.0/fpm/entrypoint.sh +++ b/17.0/fpm/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/18.0/apache/entrypoint.sh b/18.0/apache/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/18.0/apache/entrypoint.sh +++ b/18.0/apache/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/18.0/fpm-alpine/entrypoint.sh b/18.0/fpm-alpine/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/18.0/fpm-alpine/entrypoint.sh +++ b/18.0/fpm-alpine/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/18.0/fpm/entrypoint.sh b/18.0/fpm/entrypoint.sh index fb2fe686..3f888c69 100755 --- a/18.0/fpm/entrypoint.sh +++ b/18.0/fpm/entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' diff --git a/README.md b/README.md index 8721eb66..cc020b81 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,8 @@ To use an external SMTP server, you have to provide the connection details. To c Check the [Nextcloud documentation](https://docs.nextcloud.com/server/15/admin_manual/configuration_server/email_configuration.html) for other values to configure SMTP. +To insert custom config for nextcloud, you can insert a seed config.php into the image (for example, you might mount a secret), and set `NEXTCLOUD_CONFIG_BOOTSTRAP_FILE` to the filename of your seed config file. The config file must be valid PHP, in the same format as the normal config.php file. The config file will only be used on new installations - it will not override config on update, or when restarting the container. + # Running this image with docker-compose The easiest way to get a fully featured and functional setup is using a `docker-compose` file. There are too many different possibilities to setup your system, so here are only some examples of what you have to look for. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index fb2fe686..3f888c69 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -79,6 +79,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" + if [ -n "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE+x}" ] ; then + cp "${NEXTCLOUD_CONFIG_BOOTSTRAP_FILE}" /var/www/html/config/config.php + fi + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then # shellcheck disable=SC2016 install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"'