# HG changeset patch # User Tero Marttila # Date 1334232274 -10800 # Node ID a8160670c3cb03b3c503ad9361c27e90a405c2cd # Parent e0576a968171616aadc68e98a1601c92e6538f02 lib/update.operations: implement choose_zone to choose correct base for zone from settings/*.zone diff -r e0576a968171 -r a8160670c3cb lib/update.operations --- a/lib/update.operations Sat Mar 24 10:38:57 2012 +0200 +++ b/lib/update.operations Thu Apr 12 15:04:34 2012 +0300 @@ -167,20 +167,35 @@ copy_generic $out $src } +## Return the first zone that exists under $DATA/$name.zone +# +# base=$(choose_zone $name...) +function choose_zone { + # look + for name in "$@"; do + if [ $name ] && [ -e $DATA/$name.zone ]; then + echo $name + return 0 + fi + done + + # failed to find + die "Unable to find zone in $DATA/*.zone: $@" +} + ## Expand zone file from source using $BIN/expand-zone: # # update_zone $view $zone [$base] # -# Processed $DATA/$base zone data through $BIN/expand-zone, writing output to $ZONES/$view/$zone. +# Updates $ZONES/$view/$zone from $DATA/$base.{zone,serial} using $BIN/expand-zone. function update_zone { local view=$1 local zone=$2 local base=${3:-$zone} + # zones <- data+serial file local out=$ZONES/$view/$zone local src=$DATA/$base.zone - local lnk=$ZONES/$base - local serial=$SERIALS/$base.serial if check_update $out $src $serial; then