cleanup main update script somewhat dns-new
authorTero Marttila <terom@paivola.fi>
Thu, 19 Dec 2013 22:00:37 +0200
branchdns-new
changeset 94 1b02d8075676
parent 93 1a313b7b6d40
child 95 a756f317d083
cleanup main update script somewhat
bin/update
lib/update
lib/update.config
lib/update.operations
--- a/bin/update	Thu Dec 19 21:04:07 2013 +0200
+++ b/bin/update	Thu Dec 19 22:00:37 2013 +0200
@@ -1,8 +1,7 @@
 #!/bin/bash
 # vim: set ft=sh :
 
-set -ue
-
+# Bootstrap
 if [ $0 == './update' ]; then
     SRV=$(pwd)
     OPT=./opt
@@ -12,34 +11,8 @@
     cd $SRV
 fi
 
-# charset for files under etc/
-CHARSET='utf-8'
-
-# External bins
-NAMED_CHECKZONE=/usr/sbin/named-checkzone
-
-DHCPD=/usr/sbin/dhcpd
-DHCPD_CONF=/etc/dhcp/dhcpd.conf
-DHCPD_INIT=/etc/init.d/isc-dhcp-server
-
-HG=/usr/bin/hg
-HG_ARGS=(--config trusted.users=root)
-
-RNDC=/usr/sbin/rndc
-RNDC_KEY=/etc/bind/rndc.key
-
-# Library includes
 source lib/update
 
-## Flags
-# set by do_reload_zone if zone data has actually been reloaded
-RELOAD_ZONES=
-
-## Site settings, used as arguments to scripts
-# Origin domain to generate reverse records for in --reverse-zone
-REVERSE_DOMAIN=paivola.fi
-
-## Do things
 function update {
     log "Testing hosts..."
     for hosts in $(list_files etc/hosts); do
@@ -86,7 +59,9 @@
     for conf in $(list_files etc/dhcp); do
         update_dhcp_conf    "var/dhcp/$conf"                "etc/dhcp/$conf"
     done
-    
+}
+
+function deploy {
     ## Check
     log "Testing zones..."
     for zone in $(list_files etc/zones); do
@@ -98,7 +73,6 @@
         check_dhcp          $conf
     done
 
-    ## Deploy
     log "Reload zones..."
         reload_zones
 
@@ -135,6 +109,7 @@
 
     ## Go
     update
+    deploy
 }
 
 main "$@"
--- a/lib/update	Thu Dec 19 21:04:07 2013 +0200
+++ b/lib/update	Thu Dec 19 22:00:37 2013 +0200
@@ -1,5 +1,9 @@
 #!/bin/bash
 #
+
+## Strict errors
+set -ue
+
 ## Library includes
 for lib in lib/update.*; do
     source $lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/update.config	Thu Dec 19 22:00:37 2013 +0200
@@ -0,0 +1,16 @@
+# charset for files under etc/
+CHARSET='utf-8'
+
+# External bins
+NAMED_CHECKZONE=/usr/sbin/named-checkzone
+
+DHCPD=/usr/sbin/dhcpd
+DHCPD_CONF=/etc/dhcp/dhcpd.conf
+DHCPD_INIT=/etc/init.d/isc-dhcp-server
+
+HG=/usr/bin/hg
+HG_ARGS=(--config trusted.users=root)
+
+RNDC=/usr/sbin/rndc
+RNDC_KEY=/etc/bind/rndc.key
+
--- a/lib/update.operations	Thu Dec 19 21:04:07 2013 +0200
+++ b/lib/update.operations	Thu Dec 19 22:00:37 2013 +0200
@@ -251,6 +251,9 @@
 }
 
 ### Deploy
+# set by do_reload_zone if zone data has actually been reloaded
+RELOAD_ZONES=
+
 ## Run rndc reload
 function do_reload_zones {
     # run