Modification : vm_hosted -> etc/sv/*/configure.sh .
[lhc/ateliers.git] / etc / sv / nsd3 / configure.sh
diff --git a/etc/sv/nsd3/configure.sh b/etc/sv/nsd3/configure.sh
new file mode 100644 (file)
index 0000000..0e870e3
--- /dev/null
@@ -0,0 +1,40 @@
+rule apt_get_install nsd
+rule insserv_remove  nsd3
+sudo rm -rf \
+ /etc/nsd3/zone.d
+sudo install -d -m 750 -o root -g nsd \
+ /etc/nsd3/zone.d
+{
+       cat <<-EOF
+               server:
+                       ip-address: $vm_ipv4
+                       ip4-only: yes
+               EOF
+       cat "$tool"/etc/nsd3/nsd.conf
+       local conf
+       for conf in "$tool"/etc/nsd3/zone.d/*.conf
+        do conf=${conf#"$tool"/etc/nsd3/zone.d/}
+               local domain=${conf%.conf}
+               if test -e "$tool"/etc/nsd3/zone.d/"$domain".zone.m4
+                then m4 \
+                        --define=ZONE_DOMAIN=$domain \
+                        --define=ZONE_SERIAL=$(cd "$tool" && git log -1 --format="%ct" -- etc/nsd3/zone.d/"$domain".zone.m4) \
+                        --define=VM_IP4=$vm_ipv4 \
+                               "$tool"/etc/nsd3/zone.d/"$domain".zone.m4
+                else cat "$tool"/etc/nsd3/zone.d/"$domain".zone
+                fi |
+               sudo install -m 440 -o root -g nsd /dev/stdin \
+                /etc/nsd3/zone.d/"$domain".zone
+               sudo install -m 440 -o root -g nsd \
+                "$tool"/etc/nsd3/zone.d/"$conf" \
+                       /etc/nsd3/zone.d/"$conf"
+               cat <<-EOF
+                       zone:
+                               name: $domain
+                               zonefile: /etc/nsd3/zone.d/$domain.zone
+                       EOF
+        done
+} |
+sudo install -m 640 -o root -g nsd /dev/stdin \
+ /etc/nsd3/nsd.conf
+sudo nsdc rebuild