0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-04-19 18:36:09 +02:00

Add ability to force reinitialization by putting a marker file in the tmp folder

We have a custom image where we'd like to recopy all of nextcloud's
source code again when we update some internal thing without a change in
Nextcloud's version. The newly added pre-initialization hook can be used
to determine this and force a rerun.

Signed-off-by: Stephan Brunner <s.brunner@stephan-brunner.net>
This commit is contained in:
Stephan Brunner 2025-03-02 09:31:13 +01:00
parent 5bbbde3734
commit d6b4877b36
11 changed files with 169 additions and 9 deletions

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
run_path post-installation run_path post-installation
fi fi
fi fi
# not enough specified to do a fully automated installation # not enough specified to do a fully automated installation
if [ "$install" = false ]; then if [ "$install" = false ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi

View file

@ -393,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` # 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. 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.

View file

@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
exit 1 exit 1
fi fi
need_initialization=false
if version_greater "$image_version" "$installed_version"; then 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
run_path post-upgrade run_path post-upgrade
fi fi
if [ -f /tmp/nextcloud-force-initialization ]; then
rm /tmp/nextcloud-force-initialization
fi
echo "Initializing finished" echo "Initializing finished"
fi fi