From 5bbbde3734f0030f311f4a4b4c3c01dcd741fc9f Mon Sep 17 00:00:00 2001 From: Stephan Brunner Date: Sun, 2 Mar 2025 09:28:19 +0100 Subject: [PATCH] Add pre-initialization hook Allow execution of scripts even before the need to install or update Nextcloud is determined. Useful when needing to have additional update condition checks. Signed-off-by: Stephan Brunner --- 29/apache/Dockerfile | 3 ++- 29/apache/entrypoint.sh | 2 ++ 29/fpm-alpine/Dockerfile | 3 ++- 29/fpm-alpine/entrypoint.sh | 2 ++ 29/fpm/Dockerfile | 3 ++- 29/fpm/entrypoint.sh | 2 ++ 30/apache/Dockerfile | 3 ++- 30/apache/entrypoint.sh | 2 ++ 30/fpm-alpine/Dockerfile | 3 ++- 30/fpm-alpine/entrypoint.sh | 2 ++ 30/fpm/Dockerfile | 3 ++- 30/fpm/entrypoint.sh | 2 ++ 31/apache/Dockerfile | 3 ++- 31/apache/entrypoint.sh | 2 ++ 31/fpm-alpine/Dockerfile | 3 ++- 31/fpm-alpine/entrypoint.sh | 2 ++ 31/fpm/Dockerfile | 3 ++- 31/fpm/entrypoint.sh | 2 ++ Dockerfile-alpine.template | 3 ++- Dockerfile-debian.template | 3 ++- README.md | 4 +++- docker-entrypoint.sh | 2 ++ 22 files changed, 45 insertions(+), 12 deletions(-) diff --git a/29/apache/Dockerfile b/29/apache/Dockerfile index 3ca9ab54..ae0e703c 100644 --- a/29/apache/Dockerfile +++ b/29/apache/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/29/apache/entrypoint.sh +++ b/29/apache/entrypoint.sh @@ -141,6 +141,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 diff --git a/29/fpm-alpine/Dockerfile b/29/fpm-alpine/Dockerfile index 47179e44..936e7644 100644 --- a/29/fpm-alpine/Dockerfile +++ b/29/fpm-alpine/Dockerfile @@ -135,7 +135,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 8e178f2e..118e9b73 100755 --- a/29/fpm-alpine/entrypoint.sh +++ b/29/fpm-alpine/entrypoint.sh @@ -141,6 +141,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 diff --git a/29/fpm/Dockerfile b/29/fpm/Dockerfile index 3a984575..231472ae 100644 --- a/29/fpm/Dockerfile +++ b/29/fpm/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/29/fpm/entrypoint.sh +++ b/29/fpm/entrypoint.sh @@ -141,6 +141,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 diff --git a/30/apache/Dockerfile b/30/apache/Dockerfile index 472e005d..dc3d457c 100644 --- a/30/apache/Dockerfile +++ b/30/apache/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/30/apache/entrypoint.sh +++ b/30/apache/entrypoint.sh @@ -141,6 +141,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 diff --git a/30/fpm-alpine/Dockerfile b/30/fpm-alpine/Dockerfile index b060e713..b7db0a9e 100644 --- a/30/fpm-alpine/Dockerfile +++ b/30/fpm-alpine/Dockerfile @@ -135,7 +135,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 8e178f2e..118e9b73 100755 --- a/30/fpm-alpine/entrypoint.sh +++ b/30/fpm-alpine/entrypoint.sh @@ -141,6 +141,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 diff --git a/30/fpm/Dockerfile b/30/fpm/Dockerfile index 85d0f477..102ae6d2 100644 --- a/30/fpm/Dockerfile +++ b/30/fpm/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/30/fpm/entrypoint.sh +++ b/30/fpm/entrypoint.sh @@ -141,6 +141,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 diff --git a/31/apache/Dockerfile b/31/apache/Dockerfile index 96b8511c..98736153 100644 --- a/31/apache/Dockerfile +++ b/31/apache/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/31/apache/entrypoint.sh +++ b/31/apache/entrypoint.sh @@ -141,6 +141,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 diff --git a/31/fpm-alpine/Dockerfile b/31/fpm-alpine/Dockerfile index ca69007f..802c4c18 100644 --- a/31/fpm-alpine/Dockerfile +++ b/31/fpm-alpine/Dockerfile @@ -135,7 +135,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 8e178f2e..118e9b73 100755 --- a/31/fpm-alpine/entrypoint.sh +++ b/31/fpm-alpine/entrypoint.sh @@ -141,6 +141,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 diff --git a/31/fpm/Dockerfile b/31/fpm/Dockerfile index 68c7b75f..fe788fe9 100644 --- a/31/fpm/Dockerfile +++ b/31/fpm/Dockerfile @@ -140,7 +140,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 8e178f2e..118e9b73 100755 --- a/31/fpm/entrypoint.sh +++ b/31/fpm/entrypoint.sh @@ -141,6 +141,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 diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 2295bddf..d256d3da 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -134,7 +134,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 8734caa9..c0bd4dd9 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -139,7 +139,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 9f13f17c..f67f9ffc 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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8e178f2e..118e9b73 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -141,6 +141,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