LibrePortal/scripts/app/containers/nextcloud/nextcloud_toggle_maintenance.sh
librelad 3ecf213cab refactor(de-sudo): docker calls via runFileOp/dockerCommandRun, drop sudo
Container-plane docker now routes through the mode-aware helpers instead of
sudo: simple calls (exec/ps/run/build/images/inspect/port/logs across ~15
app/check scripts) -> runFileOp docker (rootless socket as the install user;
rooted via the docker group). The cd && docker compose paths drop the sudo on
the rooted branch (the rootless branch already used dockerCommandRunInstallUser
-- byte-identical now, manager-ready later); gluetun, which had no rootless
branch, now uses dockerCommandRun so force-recreate works in both modes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-24 16:29:22 +01:00

22 lines
736 B
Bash

#!/bin/bash
# Flip Nextcloud's maintenance mode. With maintenance on, all users are locked
# out and Nextcloud only serves a notice — required before running occ upgrades.
appNextcloudToggleMaintenance() {
local args="$1"
local enable
enable="$(authToolArg "$args" enable)"
local target=--off
[[ "$enable" == "true" ]] && target=--on
local out
out=$(runFileOp docker exec -u www-data nextcloud-service php occ maintenance:mode $target 2>&1)
if echo "$out" | grep -qi "maintenance mode (enabled\|already enabled\|disabled\|already disabled)"; then
isSuccessful "Nextcloud maintenance mode $target."
return 0
fi
isError "Nextcloud maintenance toggle failed: $out"; return 1
}