diff --git a/34/entrypoint.sh b/34/entrypoint.sh index 88ef462..770e85e 100644 --- a/34/entrypoint.sh +++ b/34/entrypoint.sh @@ -289,9 +289,32 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi # Upgrade else + run_path pre-upgrade - run_as 'php /var/www/html/occ upgrade' + echo "Enabling maintenance mode..." + run_as 'php /var/www/html/occ maintenance:mode --on' + + # Start Apache early so users get the maintenance page + if expr "$1" : "apache" 1>/dev/null; then + echo "Starting Apache in background..." + apache2-foreground & + APACHE_PID=$! + + # Give Apache a few seconds to start + sleep 3 + fi + + echo "Running Nextcloud upgrade..." + if run_as 'php /var/www/html/occ upgrade'; then + echo "Upgrade completed." + + echo "Disabling maintenance mode..." + run_as 'php /var/www/html/occ maintenance:mode --off' + else + echo "Upgrade failed! Leaving maintenance mode enabled." + exit 1 + fi get_enabled_apps > /tmp/list_after disabled_apps="$(comm -23 /tmp/list_before /tmp/list_after || true)" @@ -302,6 +325,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP rm -f /tmp/list_before /tmp/list_after run_path post-upgrade + fi echo "Initializing finished" @@ -327,4 +351,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP run_path before-starting fi -exec "$@" \ No newline at end of file +# If Apache was already started during upgrade, +# keep this process attached to it. +if [ -n "${APACHE_PID:-}" ]; then + echo "Apache already running." + wait "$APACHE_PID" +else + exec "$@" +fi \ No newline at end of file diff --git a/35 b/35 new file mode 120000 index 0000000..3e932fe --- /dev/null +++ b/35 @@ -0,0 +1 @@ +34 \ No newline at end of file