Fix permission denied when --force overwrites root-owned config files

When Docker containers write config files (e.g. searxng/settings.yml),
those files end up owned by root. write_if_new now falls back to
sudo tee when the destination file exists but is not writable.

https://claude.ai/code/session_012gDnantBmFTWZGCiKyjazx
This commit is contained in:
Claude
2026-03-21 02:49:51 +00:00
parent cd150a7911
commit 55cfa71464
+5 -1
View File
@@ -535,7 +535,11 @@ write_if_new() {
local dest="$1"
local content; content=$(cat)
if [[ ! -f "$dest" ]] || $FORCE; then
printf '%s\n' "$content" > "$dest"
if [[ -e "$dest" ]] && [[ ! -w "$dest" ]]; then
printf '%s\n' "$content" | sudo tee "$dest" > /dev/null
else
printf '%s\n' "$content" > "$dest"
fi
ok "Wrote $(basename "$dest")"
else
info "Kept $(basename "$dest") (--force to overwrite)"