update: copy_generic; use copy_dhcp_conf to get diffs
authorTero Marttila <terom@paivola.fi>
Wed, 21 Mar 2012 17:16:26 +0200
changeset 587 620f4594a09d
parent 586 a88766722d18
child 588 21b33b9090d0
update: copy_generic; use copy_dhcp_conf to get diffs
bin/update
lib/update.operations
--- a/bin/update	Wed Mar 21 17:11:00 2012 +0200
+++ b/bin/update	Wed Mar 21 17:16:26 2012 +0200
@@ -190,11 +190,11 @@
 
 # Update $DHCP files from $DATA/dhcp
 function run_dhcp {
-    log "Linking DHCP configs..."
+    log "Copying DHCP configs..."
         for conf in "${DHCP_CONFS[@]}"; do
             #                   conf               base
             check_dhcp_conf     $conf
-            link_dhcp_conf      $conf
+            copy_dhcp_conf      $conf
         done
 
     log "Testing dhcp..."
--- a/lib/update.operations	Wed Mar 21 17:11:00 2012 +0200
+++ b/lib/update.operations	Wed Mar 21 17:16:26 2012 +0200
@@ -17,6 +17,19 @@
     fi
 }
 
+function copy_generic {
+    local out=$1
+    local src=$2
+
+    if check_update $out $src; then
+        log_update "Copying $out <- $src..."
+
+        do_update $out \
+            cat $ROOT/$src
+    else
+        log_skip "Copying $out <- $src: not changed"
+    fi
+}
 
 ## Hosts
 ## Update hosts from verbatim from input zone data:
@@ -28,14 +41,11 @@
     local zone=$1
     local base=$2
 
-    if check_update $zone $base; then
-        log_update "Copying hosts $zone <- $base..."
+    # XXX: filenames given directly
+    local out=$zone
+    local src=$base
 
-        do_update $zone \
-            cat $ROOT/$base
-    else
-        log_skip "Copying hosts $zone <- $base: not changed"
-    fi
+    copy_generic $out $src
 }
 
 ## Generate hosts from input zone data using $BIN/process-zone:
@@ -118,7 +128,6 @@
     local out=$SERIALS/$zone.serial
     local tgt=$SERIALS/$base.serial
 
-
     link_generic $out $tgt
 }
 
@@ -135,14 +144,7 @@
     local out=$ZONES/$view/$zone
     local src=$DATA/$base
 
-    if check_update $out $src; then
-        log_update "Copying $out <- $src..."
-
-        do_update $out \
-            cat $ROOT/$src
-    else
-        log_skip "Copying $out <- $src: not changed"
-    fi
+    copy_generic $out $src
 }
 
 ## Expand zone file from source using $BIN/expand-zone:
@@ -203,6 +205,17 @@
     link_generic $out $tgt
 }
 
+## Copy dhcp conf from data to $DHCP
+function copy_dhcp_conf {
+    local conf=$1
+    local base=${2:-$conf}
+
+    local out=$DHCP/$conf.conf
+    local src=$DHCP_DATA/$base.conf
+
+    copy_generic $out $src
+}
+
 ## Test hosts zone for validity:
 #
 #   check_hosts     $DATA/$hosts    --check-exempt ...