# HG changeset patch # User Tero Marttila # Date 1332341159 -7200 # Node ID 22b58b938fd06215bf7e3dfbd97f48ca76f47506 # Parent b65ce9123039fc46394aa26178563210c3ff1792 update: rename deploy_zones -> reload_zones; move related do_* from lib/update.updates -> lib/update.operations where they belong diff -r b65ce9123039 -r 22b58b938fd0 bin/update --- a/bin/update Tue Mar 20 15:07:03 2012 +0200 +++ b/bin/update Wed Mar 21 16:45:59 2012 +0200 @@ -32,6 +32,9 @@ ZONES=zones SERIALS=$DATA +DHCP_DATA=$DATA/dhcp +DHCP_HOSTS=dhcp + # hg repo to commit REPO=$DATA @@ -92,7 +95,7 @@ ## Operate! # these functions are all defined in lib/update.operations -function run { +function run_hosts { ## Hosts # test log "Testing hosts..." @@ -113,7 +116,9 @@ # XXX: unsupported --forward-zone with pvl.txt # update_hosts $ZONES/hosts/pvl $DATA/pvl.txt --forward-zone copy_hosts $ZONES/hosts/pvl $DATA/pvl.txt - +} + +function run_zones { ## Includes log "Copying zone includes..." # view zone base @@ -172,10 +177,12 @@ check_zone $view $zone $zone done done +} - ## Deploy - log "Deploy zones..." - deploy_zones +function run_deploy { + ## Reload zones + log "Reload zones..." + reload_zones ## Commit log "Commit data..." @@ -199,7 +206,9 @@ done ## Go - run + run_hosts + run_zones + run_deploy } main "$@" diff -r b65ce9123039 -r 22b58b938fd0 lib/update.args --- a/lib/update.args Tue Mar 20 15:07:03 2012 +0200 +++ b/lib/update.args Wed Mar 21 16:45:59 2012 +0200 @@ -30,8 +30,8 @@ COMMIT_FORCE= COMMIT_MSG=' ' -DEPLOY_NOOP= -DEPLOY_FORCE= +RELOAD_NOOP= +RELOAD_FORCE= ## Output command-line argument help. function help_args { @@ -108,15 +108,15 @@ UPDATE_DIFF=y SERIAL_NOUPDATE=y COMMIT_SKIP=y - DEPLOY_NOOP=y + RELOAD_NOOP=y ;; C) COMMIT_SKIP=y ;; c) COMMIT_FORCE=y ;; m) COMMIT_MSG="$OPTARG" ;; - R) DEPLOY_NOOP=y ;; - r) DEPLOY_FORCE=y ;; + R) RELOAD_NOOP=y ;; + r) RELOAD_FORCE=y ;; ?) die diff -r b65ce9123039 -r 22b58b938fd0 lib/update.operations --- a/lib/update.operations Tue Mar 20 15:07:03 2012 +0200 +++ b/lib/update.operations Wed Mar 21 16:45:59 2012 +0200 @@ -42,6 +42,27 @@ fi } +## Update .serial number: +# +# do_update_serial $serial +# +# Shows old/new serial on debug. +function do_update_serial { + local serial=$1 + + # read + local old=$(test -e $ROOT/$serial && cat $ROOT/$serial || echo '') + + + cmd $BIN/update-serial $ROOT/$serial + + # read + local new=$(cat $ROOT/$serial) + + debug " $old -> $new" +} + + ## Generate new serial for zone using $BIN/update-serial, if the zone data has changed: # # update_serial $zone $deps... @@ -227,18 +248,18 @@ ## Load update zonefiles into bind: # -# deploy_zones +# reload_zones # # Invokes `rndc reload`, showing its output. -function deploy_zones { +function reload_zones { local msg="Reload zones" - if [ $DEPLOY_FORCE ]; then + if [ $RELOAD_FORCE ]; then log_force "$msg..." do_reload - elif [ $DEPLOY_NOOP ]; then + elif [ $RELOAD_NOOP ]; then log_noop "$msg: skipped" elif [ ! -r $RNDC_KEY ]; then @@ -253,6 +274,17 @@ do_reload fi } + +## Perform `hg commit` for $DATA +function do_commit { + local msg=$1 + + [ $LOG_DIFF ] && indent " " hg_diff + + hg_commit "$msg" +} + + ## Commit changes in $DATA to version control: # # commit_data diff -r b65ce9123039 -r 22b58b938fd0 lib/update.updates --- a/lib/update.updates Tue Mar 20 15:07:03 2012 +0200 +++ b/lib/update.updates Wed Mar 21 16:45:59 2012 +0200 @@ -132,33 +132,3 @@ cmd ln -sf $ROOT/$tgt $ROOT/$lnk } -## Update .serial number: -# -# do_update_serial $serial -# -# Shows old/new serial on debug. -function do_update_serial { - local serial=$1 - - # read - local old=$(test -e $ROOT/$serial && cat $ROOT/$serial || echo '') - - - cmd $BIN/update-serial $ROOT/$serial - - # read - local new=$(cat $ROOT/$serial) - - debug " $old -> $new" -} - -## Perform `hg commit` for $DATA -function do_commit { - local msg=$1 - - [ $LOG_DIFF ] && indent " " hg_diff - - hg_commit "$msg" -} - -