LibrePortal/scripts/app/containers/nextcloud/nextcloud_add_trusted_domain.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

25 lines
1.0 KiB
Bash

#!/bin/bash
# Append a hostname to Nextcloud's trusted_domains array — required for any
# host Nextcloud should accept HTTP requests on. The index is auto-picked as
# `last + 1` from the existing array so we never collide.
appNextcloudAddTrustedDomain() {
local args="$1"
local domain
domain="$(authToolArg "$args" domain)"
[[ -z "$domain" ]] && { isError "Domain is required."; return 1; }
local current_count
current_count=$(runFileOp docker exec -u www-data nextcloud-service php occ config:system:get trusted_domains 2>/dev/null | grep -c '^\s*[0-9]')
[[ -z "$current_count" || "$current_count" -lt 1 ]] && current_count=1
local out
out=$(runFileOp docker exec -u www-data nextcloud-service php occ config:system:set trusted_domains "$current_count" --value="$domain" 2>&1)
if echo "$out" | grep -qi "system config value\|set to string"; then
isSuccessful "Nextcloud trusted_domains[$current_count] = $domain"
return 0
fi
isError "Nextcloud add-trusted-domain failed: $out"; return 1
}