[8598] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Deploy fresh/changed WL autogenerated DNS zones
|
---|
| 4 | #
|
---|
[9954] | 5 | GENESISROOT=`cd $(dirname $0)/..; pwd -P`
|
---|
| 6 | TOOLS="$GENESISROOT/tools"
|
---|
| 7 | CONFIG="$GENESISROOT/nodes"
|
---|
| 8 | STATIC="$GENESISROOT/dns"
|
---|
[8598] | 9 | DEPLOYROOT='/etc/namedb/master'
|
---|
| 10 |
|
---|
| 11 | TFILE=`mktemp /tmp/$(basename $0).XXXXX`
|
---|
| 12 | trap "rm $TFILE; exit 1" 1 2 3 15
|
---|
| 13 |
|
---|
[9954] | 14 | FORCE_UPDATE=${FORCE_UPDATE:-"no"}
|
---|
| 15 | ACTIVATE=${ACTIVATE:-"yes"}
|
---|
| 16 |
|
---|
[8598] | 17 | # Generate new DNS and only complain/die on errors
|
---|
| 18 | (
|
---|
[9954] | 19 | #svn up $GENESISROOT || exit 1
|
---|
| 20 | #$TOOLS/genesis-to-yaml.pl $CONFIG/*/wleiden.conf || exit 1
|
---|
| 21 | $TOOLS/gformat.py dns || exit 1
|
---|
[8598] | 22 | ) 2>&1 > $TFILE || { cat $TFILE; exit 1; }
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | UPDATE_ZONES=""
|
---|
[9954] | 26 | # Check all zone files for vadility and updates
|
---|
| 27 | for NEW in $CONFIG/dns/*; do
|
---|
[8598] | 28 | ZONE=`basename $NEW | cut -c 4-`
|
---|
| 29 | OLD=$DEPLOYROOT/`basename $NEW`
|
---|
| 30 |
|
---|
| 31 | # Syntax valid?
|
---|
[9954] | 32 | named-checkzone -q $ZONE $NEW
|
---|
[8598] | 33 | if [ $? -ne 0 ] ; then
|
---|
[9954] | 34 | echo "# ERROR: $ZONE FAILED"
|
---|
[9955] | 35 | named-checkzone $ZONE $NEW
|
---|
[9954] | 36 | else
|
---|
| 37 | echo "# INFO: $ZONE - OK"
|
---|
[8598] | 38 | fi
|
---|
| 39 |
|
---|
[9954] | 40 | if [ -r "$OLD" -a "$FORCE_UPDATE" = "no" ]; then
|
---|
| 41 | # Contains new data?
|
---|
| 42 | diff -I 'SOA' $OLD $NEW
|
---|
| 43 | if [ $? -eq 0 ]; then
|
---|
| 44 | continue
|
---|
| 45 | fi
|
---|
| 46 | fi
|
---|
| 47 |
|
---|
[8598] | 48 | # Deploy
|
---|
[9954] | 49 | if [ "$ACTIVATE" = "yes" ]; then
|
---|
| 50 | cp $NEW $OLD
|
---|
| 51 | UPDATE_ZONES="$UPDATE_ZONES $ZONE"
|
---|
| 52 | fi
|
---|
[8598] | 53 | done
|
---|
| 54 |
|
---|
| 55 | # Make sure to reload if updates are executed
|
---|
| 56 | if [ -n "$UPDATE_ZONES" ]; then
|
---|
| 57 | rndc reload
|
---|
| 58 | fi
|
---|