Modifications : etc/nsd3/nsd.conf -> etc/nsd/nsd.conf
[lhc/ateliers.git] / etc / sv / nsd / local.sh
diff --git a/etc/sv/nsd/local.sh b/etc/sv/nsd/local.sh
new file mode 100644 (file)
index 0000000..180a6d0
--- /dev/null
@@ -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