0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2024-11-17 18:46:43 +01:00

Allow simultaneous initialization of common html volume

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2022-04-11 14:17:19 +02:00 committed by John Molakvoæ
parent e76b7cab35
commit 35b8ebf954
2 changed files with 104 additions and 81 deletions

View file

@ -101,6 +101,24 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
else else
rsync_options="-rlD" rsync_options="-rlD"
fi fi
# If another process is syncing the html folder, wait for
# it to be done, then escape initalization
lock=/var/www/html/nextcloud-init-sync.lock
count=0
if [ -f "$lock" ]; then
until [ ! -f "$lock" ]
do
count=$((count+1))
wait=$((count*10))
echo "Another process is initializing Nextcloud. Waiting $wait seconds..."
sleep $wait
done
echo "The other process is done, assuming complete initialization"
else
# Prevent multiple images syncing simultaneously
touch $lock
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
for dir in config data custom_apps themes; do for dir in config data custom_apps themes; do
@ -109,9 +127,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
done done
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
echo "Initializing finished"
#install # Install
if [ "$installed_version" = "0.0.0.0" ]; then if [ "$installed_version" = "0.0.0.0" ]; then
echo "New nextcloud instance" echo "New nextcloud instance"
@ -152,21 +169,21 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
if [ "$install" = true ]; then if [ "$install" = true ]; then
echo "starting nextcloud installation" echo "Starting nextcloud installation"
max_retries=10 max_retries=10
try=0 try=0
until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ]
do do
echo "retrying install..." echo "Retrying install..."
try=$((try+1)) try=$((try+1))
sleep 10s sleep 10s
done done
if [ "$try" -gt "$max_retries" ]; then if [ "$try" -gt "$max_retries" ]; then
echo "installing of nextcloud failed!" echo "Installing of nextcloud failed!"
exit 1 exit 1
fi fi
if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then
echo "setting trusted domains…" echo "Setting trusted domains…"
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
@ -175,10 +192,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
done done
fi fi
else else
echo "running web-based installer on first connect!" echo "Please run the web-based installer on first connect!"
fi fi
fi fi
#upgrade # Upgrade
else else
run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ upgrade'
@ -188,6 +205,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after
fi fi
# Initialization done, reset lock
rm $lock
echo "Initializing finished"
fi
fi fi
fi fi

View file

@ -3,3 +3,4 @@
/custom_apps/ /custom_apps/
/themes/ /themes/
/version.php /version.php
/nextcloud-init-sync.lock