diff --git a/29/apache/Dockerfile b/29/apache/Dockerfile index 962f1bca..6aa4d6c0 100644 --- a/29/apache/Dockerfile +++ b/29/apache/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/29/apache/entrypoint.sh b/29/apache/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/29/apache/entrypoint.sh +++ b/29/apache/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/29/fpm-alpine/Dockerfile b/29/fpm-alpine/Dockerfile index 937ae5dc..b3e72848 100644 --- a/29/fpm-alpine/Dockerfile +++ b/29/fpm-alpine/Dockerfile @@ -119,7 +119,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/29/fpm-alpine/entrypoint.sh b/29/fpm-alpine/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/29/fpm-alpine/entrypoint.sh +++ b/29/fpm-alpine/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/29/fpm/Dockerfile b/29/fpm/Dockerfile index 2d5ff91a..ad1933ff 100644 --- a/29/fpm/Dockerfile +++ b/29/fpm/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/29/fpm/entrypoint.sh b/29/fpm/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/29/fpm/entrypoint.sh +++ b/29/fpm/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/30/apache/Dockerfile b/30/apache/Dockerfile index 31d62217..ce637572 100644 --- a/30/apache/Dockerfile +++ b/30/apache/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/30/apache/entrypoint.sh b/30/apache/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/30/apache/entrypoint.sh +++ b/30/apache/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/30/fpm-alpine/Dockerfile b/30/fpm-alpine/Dockerfile index 09e10d33..10584886 100644 --- a/30/fpm-alpine/Dockerfile +++ b/30/fpm-alpine/Dockerfile @@ -119,7 +119,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/30/fpm-alpine/entrypoint.sh b/30/fpm-alpine/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/30/fpm-alpine/entrypoint.sh +++ b/30/fpm-alpine/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/30/fpm/Dockerfile b/30/fpm/Dockerfile index 8cbb07d3..48c6d5d0 100644 --- a/30/fpm/Dockerfile +++ b/30/fpm/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/30/fpm/entrypoint.sh b/30/fpm/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/30/fpm/entrypoint.sh +++ b/30/fpm/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/31/apache/Dockerfile b/31/apache/Dockerfile index 6421c7b0..23abebd9 100644 --- a/31/apache/Dockerfile +++ b/31/apache/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/31/apache/entrypoint.sh b/31/apache/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/31/apache/entrypoint.sh +++ b/31/apache/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/31/fpm-alpine/Dockerfile b/31/fpm-alpine/Dockerfile index a20a12e8..b590b88e 100644 --- a/31/fpm-alpine/Dockerfile +++ b/31/fpm-alpine/Dockerfile @@ -119,7 +119,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/31/fpm-alpine/entrypoint.sh b/31/fpm-alpine/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/31/fpm-alpine/entrypoint.sh +++ b/31/fpm-alpine/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/31/fpm/Dockerfile b/31/fpm/Dockerfile index 92f3935c..9f6f73db 100644 --- a/31/fpm/Dockerfile +++ b/31/fpm/Dockerfile @@ -124,7 +124,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/31/fpm/entrypoint.sh b/31/fpm/entrypoint.sh index e3b88f14..5a30e868 100755 --- a/31/fpm/entrypoint.sh +++ b/31/fpm/entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index cf6af0ff..c345920f 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -118,7 +118,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index cadae18a..72779c50 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -123,7 +123,8 @@ RUN { \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ mkdir /var/www/data; \ - mkdir -p /docker-entrypoint-hooks.d/pre-installation \ + mkdir -p /docker-entrypoint-hooks.d/pre-initialization \ + /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ diff --git a/README.md b/README.md index 7de62124..45ca73a0 100644 --- a/README.md +++ b/README.md @@ -362,8 +362,9 @@ As long as you have not modified any of the provided config files in `/var/www/h ## Auto configuration via hook folders -There are 5 hooks +There are 6 hooks +- `pre-initialization` Executed before the need to update or install Nextcloud is determined - `pre-installation` Executed before the Nextcloud is installed/initiated - `post-installation` Executed after the Nextcloud is installed/initiated - `pre-upgrade` Executed before the Nextcloud is upgraded @@ -383,6 +384,7 @@ To use the hooks triggered by the `entrypoint` script, either image: nextcloud:stable volumes: + - ./app-hooks/pre-initialization:/docker-entrypoint-hooks.d/pre-initialization - ./app-hooks/pre-installation:/docker-entrypoint-hooks.d/pre-installation - ./app-hooks/post-installation:/docker-entrypoint-hooks.d/post-installation - ./app-hooks/pre-upgrade:/docker-entrypoint-hooks.d/pre-upgrade @@ -391,6 +393,16 @@ To use the hooks triggered by the `entrypoint` script, either ... ``` +## Forcing an upgrade run + +Sometimes you need to force an explicit upgrade run even when the bundled Nextcloud version did not change. +An example would be when you have custom apps bundled and you want to update those. + +To do this, you can simply create a file `/tmp/nextcloud-force-initialization` before the need for an upgrade is determined. +The content is irrelevant. +You can either create this file before starting the container, or you can use the `pre-initialization` hook to create it. +After the update has successfully run, the file is removed automatically. + # Running this image with `docker compose` The easiest way to get a fully featured and functional setup is using a `compose.yaml` 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 e3b88f14..5a30e868 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -156,6 +156,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP flock 9 fi + run_path pre-initialization + installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then # shellcheck disable=SC2016 @@ -169,7 +171,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP exit 1 fi + need_initialization=false + if version_greater "$image_version" "$installed_version"; then + need_initialization=true + fi + + if [ -f /tmp/nextcloud-force-initialization ]; then + echo Found /tmp/nextcloud-force-initialization, forcing initialization + need_initialization=true + fi + + if [ "true" = "$need_initialization" ]; then echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then @@ -263,7 +276,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi run_path post-installation - fi + fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then @@ -284,6 +297,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path post-upgrade fi + if [ -f /tmp/nextcloud-force-initialization ]; then + rm /tmp/nextcloud-force-initialization + fi + echo "Initializing finished" fi