diff --git a/nix/modules/acme-dns.nix b/nix/modules/acme-dns.nix index 7f52252..c067e60 100644 --- a/nix/modules/acme-dns.nix +++ b/nix/modules/acme-dns.nix @@ -68,6 +68,14 @@ let src=/var/lib/acme/ci.commoninternet.net/acme-dns-accounts.json dst=/var/lib/acme/ci.autonomic.zone/acme-dns-accounts.json install -d -m 0700 /var/lib/acme/ci.autonomic.zone + # Preserve an existing account: it may have been re-keyed after DNS + # delegation. Re-seeding from the legacy zone would undo that change. + if [ -s "$dst" ] && jq -e "has(\"ci.autonomic.zone\")" "$dst" >/dev/null; then + chown acme:acme "$dst" + chmod 0600 "$dst" + echo "storage seed: existing account preserved" + exit 0 + fi if [ ! -s "$src" ]; then echo "storage seed: no legacy accounts.json — skipping (fresh host?)" exit 0