diff options
author | Remi Rampin <remi@rampin.org> | 2023-01-27 10:34:31 -0500 |
---|---|---|
committer | Remi Rampin <remi@rampin.org> | 2023-01-27 11:08:06 -0500 |
commit | 4667cbe14986e2f0f83e23ed539c7b231e98e9d9 (patch) | |
tree | 025957832dfb97d583b11f521f1930b6ecd4b789 /docker-entrypoint.sh | |
parent | df9653a00c52598a2b1d9dda05261f460cab85c9 (diff) |
Use flock to lock the whole upgrade process
Signed-off-by: Remi Rampin <remi@rampin.org>
Diffstat (limited to 'docker-entrypoint.sh')
-rwxr-xr-x | docker-entrypoint.sh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4dda99b8..b02b21ef 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -220,7 +220,21 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP } > /usr/local/etc/php/conf.d/redis-session.ini fi - do_install_or_upgrade + # If another process is syncing the html folder, wait for + # it to be done, then escape initalization. + # You need to define the NEXTCLOUD_INIT_LOCK environment variable + if [ -n "${NEXTCLOUD_INIT_LOCK+x}" ]; then + ( + if ! flock -n 9; then + # If we couldn't get it immediately, show a message, then wait for real + echo "Another process is initializing Nextcloud. Waiting..." + flock 9 + fi + do_install_or_upgrade + ) 9> /var/www/html/nextcloud-init-sync.lock + else + do_install_or_upgrade + fi fi exec "$@" |