X-Git-Url: https://git.cyclocoop.org/?p=lhc%2Fateliers.git;a=blobdiff_plain;f=etc%2Fsv%2Fnsd%2Flocal.sh;fp=etc%2Fsv%2Fnsd%2Flocal.sh;h=180a6d0dfebb69a111c496d48760489de23a7609;hp=0000000000000000000000000000000000000000;hb=04b8e1c63f1dc6ebadd577c54ee4006bb360320c;hpb=b24af3f2f139d71bc84cd0c807dca1c84cee833f diff --git a/etc/sv/nsd/local.sh b/etc/sv/nsd/local.sh new file mode 100644 index 0000000..180a6d0 --- /dev/null +++ b/etc/sv/nsd/local.sh @@ -0,0 +1,40 @@ +"$tool"/local/apt-get-install nsd +"$tool"/local/insserv-remove nsd + +sudo install -d -m 750 -o root -g nsd \ + /etc/nsd/zone.d +{ + cat <<-EOF + server: + ip-address: $local_ipv4 + ip4-only: yes + EOF + cat "$tool"/etc/nsd/nsd.conf + for zone in $(find "$tool"/etc/nsd/zone.d \ + -mindepth 1 -maxdepth 1 -type f \ + -name "*.conf" \ + -printf '%f\n') + do zone=${zone%.conf} + if test -e "$tool"/etc/nsd/zone.d/"$zone".zone.m4 + then m4 \ + --define=ZONE_DOMAIN=$zone \ + --define=ZONE_SERIAL=$(cd "$tool" && git log -1 --format="%ct" -- etc/nsd/zone.d/"$zone".zone.m4) \ + --define=LOCAL_IP4=$local_ipv4 \ + "$tool"/etc/nsd/zone.d/"$zone".zone.m4 + else cat "$tool"/etc/nsd/zone.d/"$zone".zone + fi | + sudo install -m 440 -o root -g nsd /dev/stdin \ + /etc/nsd/zone.d/"$zone".zone + cat <<-EOF + zone: + name: $zone + zonefile: /etc/nsd/zone.d/$zone.zone + $(cat "$tool"/etc/nsd/zone.d/"$zone".conf) + EOF + done +} | +sudo install -m 640 -o root -g nsd /dev/stdin \ + /etc/nsd/nsd.conf + +"$tool"/local/runit-sv-start "$sv" +sudo nsd-control reload