From 1cce2cdcd0279ff24253fb6eeff427d41738166e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 28 Jul 2023 11:49:41 +0200 Subject: [PATCH] Disable maintenance mode if active during occ (#2530) Signed-off-by: Daniel Hansson --- lib.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib.sh b/lib.sh index c4a7115d..19677f9c 100644 --- a/lib.sh +++ b/lib.sh @@ -1179,7 +1179,20 @@ fi # Example: nextcloud_occ 'maintenance:mode --on' nextcloud_occ() { +# Disable maintenance mode if enabled to be able to perform db task and notify +if sudo -u www-data php "$NCPATH"/occ maintenance:mode | grep enabled +then + sudo -u www-data php "$NCPATH"/occ maintenance:mode --off + MMODE=enabled +fi +# Run the actual command check_command sudo -u www-data php "$NCPATH"/occ "$@"; +# Enable maintenance:mode again if it was enabled when running this function +if [ -n "$MMODE" ] +then + sudo -u www-data php "$NCPATH"/occ maintenance:mode --on + unset MMODE +fi } # Example: nextcloud_occ_no_check 'maintenance:mode --on'