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