Skip to content

Commit d6b4877

Browse files
committed
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 <[email protected]>
1 parent 5bbbde3 commit d6b4877

File tree

11 files changed

+169
-9
lines changed

11 files changed

+169
-9
lines changed

29/apache/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

29/fpm-alpine/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

29/fpm/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

30/apache/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

30/fpm-alpine/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

30/fpm/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

31/apache/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

31/fpm-alpine/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

31/fpm/entrypoint.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -248,7 +259,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
248259
fi
249260

250261
run_path post-installation
251-
fi
262+
fi
252263
fi
253264
# not enough specified to do a fully automated installation
254265
if [ "$install" = false ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,16 @@ To use the hooks triggered by the `entrypoint` script, either
393393
...
394394
```
395395

396+
## Forcing an upgrade run
397+
398+
Sometimes you need to force an explicit upgrade run even when the bundled Nextcloud version did not change.
399+
An example would be when you have custom apps bundled and you want to update those.
400+
401+
To do this, you can simply create a file `/tmp/nextcloud-force-initialization` before the need for an upgrade is determined.
402+
The content is irrelevant.
403+
You can either create this file before starting the container, or you can use the `pre-initialization` hook to create it.
404+
After the update has successfully run, the file is removed automatically.
405+
396406
# Running this image with `docker compose`
397407
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.
398408

docker-entrypoint.sh

+15
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
156156
exit 1
157157
fi
158158

159+
need_initialization=false
160+
159161
if version_greater "$image_version" "$installed_version"; then
162+
need_initialization=true
163+
fi
164+
165+
if [ -f /tmp/nextcloud-force-initialization ]; then
166+
echo Found /tmp/nextcloud-force-initialization, forcing initialization
167+
need_initialization=true
168+
fi
169+
170+
if [ "true" = "$need_initialization" ]; then
160171
echo "Initializing nextcloud $image_version ..."
161172
if [ "$installed_version" != "0.0.0.0" ]; then
162173
if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then
@@ -269,6 +280,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
269280
run_path post-upgrade
270281
fi
271282

283+
if [ -f /tmp/nextcloud-force-initialization ]; then
284+
rm /tmp/nextcloud-force-initialization
285+
fi
286+
272287
echo "Initializing finished"
273288
fi
274289

0 commit comments

Comments
 (0)