From daa4ed45f5d3b84cd597454dc1ac90e1f1eeffab Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Mon, 6 Jun 2022 13:48:03 +0100 Subject: [PATCH] nixos/estuary: Fix pdns-file-records clobbering .dat ownership --- nixos/boxes/colony/vms/estuary/dns.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/boxes/colony/vms/estuary/dns.nix b/nixos/boxes/colony/vms/estuary/dns.nix index f75d694..af98562 100644 --- a/nixos/boxes/colony/vms/estuary/dns.nix +++ b/nixos/boxes/colony/vms/estuary/dns.nix @@ -13,7 +13,7 @@ let pdns-file-record = pkgs.writeShellApplication { name = "pdns-file-record"; - runtimeInputs = with pkgs; [ gnused pdns ]; + runtimeInputs = with pkgs; [ gnused moreutils pdns ]; text = '' die() { echo "$@" >&2 @@ -69,7 +69,8 @@ let # shellcheck disable=SC1090 source "$zDat" ((serial++)) - sed -i "s/^serial=.*$/serial=$serial/g" "$zDat" + # Use sponge instead of `sed -i` because that actually uses a temporary file and clobbers ownership... + sed "s/^serial=.*$/serial=$serial/g" "$zDat" | sponge "$zDat" sed "s/@@SERIAL@@/$serial/g" < /etc/pdns/bind-zones/"$zone".zone > /run/pdns/bind-zones/"$zone".zone pdns_control bind-reload-now "$zone" '';