From 55cfa71464b1e3152976fb55a310d1535fd16553 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Mar 2026 02:49:51 +0000 Subject: [PATCH] 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 --- laptop_full_setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/laptop_full_setup.sh b/laptop_full_setup.sh index 87bf63a..45577ca 100755 --- a/laptop_full_setup.sh +++ b/laptop_full_setup.sh @@ -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)"