update: full host forward/dhcp/reverse zones dns-new
authorTero Marttila <terom@paivola.fi>
Tue, 17 Dec 2013 01:17:49 +0200
branchdns-new
changeset 607 77df429f63a3
parent 606 5a83f2abc0dd
child 608 4ad9c9b7cd0e
update: full host forward/dhcp/reverse zones
bin/update
lib/update.operations
lib/update.updates
--- a/bin/update	Tue Dec 17 00:26:44 2013 +0200
+++ b/bin/update	Tue Dec 17 01:17:49 2013 +0200
@@ -47,15 +47,27 @@
         log_warn "TODO: check_hosts $hosts"
     done
 
-    log "Updating host zones..."
+    log "Updating forward host zones..."
     for hosts in $(list_files etc/hosts); do
-        update_hosts_forward    var/zones/hosts/$hosts      etc/hosts/$hosts
+        update_hosts_forward    var/zones/hosts/$hosts              $hosts \
+            etc/hosts/$hosts
     done
 
     log "Updating DHCP hosts..."
     for hosts in $(list_files etc/hosts); do
-        update_hosts_dhcp       var/dhcp/$hosts.conf        etc/hosts/$hosts
+        update_hosts_dhcp       var/dhcp/$hosts.conf                \
+            etc/hosts/$hosts
     done
+
+    log "Updating reverse host zones..."
+        update_hosts_reverse    var/zones/hosts/194.197.235         194.197.235.0/24 \
+            etc/hosts/paivola.fi etc/hosts/*.paivola.fi
+        
+        update_hosts_reverse    var/zones/hosts/10.0                10.0.0.0/16 \
+            etc/hosts/test.pvl
+        
+        update_hosts_reverse    var/zones/hosts/fdc4:4cef:395a      fdc4:4cef:395a::/48 \
+            etc/hosts/test.pvl
 }
 
 function run_zones {
--- a/lib/update.operations	Tue Dec 17 00:26:44 2013 +0200
+++ b/lib/update.operations	Tue Dec 17 01:17:49 2013 +0200
@@ -70,36 +70,61 @@
 
 ## Generate forward zone from hosts hosts using pvl.hosts-dns:
 #
-#   update_hosts out/hosts/$hosts in/hosts/$hosts
+#   update_hosts_forward out/hosts/$hosts $hosts in/hosts/$hosts
 function update_hosts_forward {
-    local out=$1
-    local src=$2
+    local out=$1; shift
+    local domain=$1; shift
+    local src=$1; shift
 
-    if check_update $out $src; then
-        log_update "Generating hosts zone $out <- $src..."
+    if check_update $out $src "$@"; then
+        log_update "Generating forward hosts zone $out <- $src..."
     
-        do_update $out $OPT/bin/pvl.hosts-dns $src \
-            --hosts-charset=$CHARSET
+        do_update $out $OPT/bin/pvl.hosts-dns \
+            --hosts-charset=$CHARSET \
+            --forward-zone=$domain \
+             $src "$@"
     
     else
-        log_skip "Generating hosts $out <- $src: not changed"
+        log_skip "Generating forward hosts $out <- $src: not changed"
     fi
 }
 
 function update_hosts_dhcp {
-    local out=$1
-    local src=$2
+    local out=$1; shift
+    local src=$1; shift
 
-    if check_update $out $src; then
+    if check_update $out $src "$@"; then
         log_update "Generating DHCP hosts $out <- $src..."
 
-        do_update $out $OPT/bin/pvl.hosts-dhcp $src \
-            --hosts-charset=$CHARSET
+        do_update $out $OPT/bin/pvl.hosts-dhcp \
+            --hosts-charset=$CHARSET \
+            $src "$@"
     else
         log_skip "Generating DHCP hosts $out <- $src: not changed"
     fi
 }
 
+## Generate reverse zone from hosts hosts using pvl.hosts-dns:
+#
+#   update_hosts_reverse out/hosts/$reverse $reverse in/hosts/$hosts
+function update_hosts_reverse {
+    local out=$1; shift
+    local reverse=$1; shift
+    local src=$1; shift
+
+    if check_update $out $src "$@"; then
+        log_update "Generating reverse hosts zone $out <- $src..."
+    
+        do_update $out $OPT/bin/pvl.hosts-dns \
+            --hosts-charset=$CHARSET \
+            --reverse-zone=$reverse \
+            $src "$@"
+    
+    else
+        log_skip "Generating reverse hosts $out <- $src: not changed"
+    fi
+}
+
 ## Update .serial number:
 #
 #   do_update_serial $serial
--- a/lib/update.updates	Tue Dec 17 00:26:44 2013 +0200
+++ b/lib/update.updates	Tue Dec 17 01:17:49 2013 +0200
@@ -36,10 +36,10 @@
         [ $update ] && continue
 
         # check
-        if [ ! -e $dep ]; then
+        if [ ! -e "$dep" ]; then
             fail "$out: Missing source: $dep"
 
-        elif [ $out -ot $dep ]; then
+        elif [ $out -ot "$dep" ]; then
             debug "  update: $dep"
             update=y
         else