Changeset 9954 in genesis for tools/fresh-dns.sh


Ignore:
Timestamp:
Feb 14, 2012, 9:38:37 AM (13 years ago)
Author:
rick
Message:

Cleanup; More hackable and readable script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/fresh-dns.sh

    r9525 r9954  
    33# Deploy fresh/changed WL autogenerated DNS zones
    44#
    5 CONFIGROOT='/usr/local/www/wlconfig/nodes/'
     5GENESISROOT=`cd $(dirname $0)/..; pwd -P`
     6TOOLS="$GENESISROOT/tools"
     7CONFIG="$GENESISROOT/nodes"
     8STATIC="$GENESISROOT/dns"
    69DEPLOYROOT='/etc/namedb/master'
    710
     
    912trap "rm $TFILE; exit 1" 1 2 3 15
    1013
     14FORCE_UPDATE=${FORCE_UPDATE:-"no"}
     15ACTIVATE=${ACTIVATE:-"yes"}
     16
    1117# Generate new DNS and only complain/die on errors
    1218(
    13   svn up $CONFIGROOT $CONFIGROOT/../dns || exit 1
    14   $CONFIGROOT/genesis-to-yaml.pl $CONFIGROOT/*/wleiden.conf || exit 1
    15   $CONFIGROOT/gformat.py dns || exit 1
     19  #svn up $GENESISROOT || exit 1
     20  #$TOOLS/genesis-to-yaml.pl $CONFIG/*/wleiden.conf || exit 1
     21  $TOOLS/gformat.py dns || exit 1
    1622) 2>&1 > $TFILE || { cat $TFILE; exit 1; }
    1723
    1824
    1925UPDATE_ZONES=""
    20 # Check all zone files for updates
    21 for NEW in $CONFIGROOT/dns/*; do
     26# Check all zone files for vadility and updates
     27for NEW in $CONFIG/dns/*; do
    2228  ZONE=`basename $NEW | cut -c 4-` 
    2329  OLD=$DEPLOYROOT/`basename $NEW`
    2430
    25   # Contains new data?
    26   diff -I 'SOA' $OLD $NEW
    27   if [ $? -eq 0 ]; then
    28     continue
     31  # Syntax valid?
     32  named-checkzone -q $ZONE $NEW
     33  if [ $? -ne 0 ] ; then
     34    echo "# ERROR: $ZONE FAILED"
     35  else
     36    echo "# INFO: $ZONE - OK"
    2937  fi
    3038
    31   # Syntax valid?
    32   named-checkzone $ZONE $NEW
    33   if [ $? -ne 0 ] ; then
    34     continue
     39  if [ -r "$OLD" -a "$FORCE_UPDATE" = "no" ]; then
     40    # Contains new data?
     41    diff -I 'SOA' $OLD $NEW
     42    if [ $? -eq 0 ]; then
     43      continue
     44    fi
    3545  fi
    3646
    3747  # Deploy
    38   cp $NEW $OLD
    39   UPDATE_ZONES="$UPDATE_ZONES $ZONE"
     48  if [ "$ACTIVATE" = "yes" ]; then
     49    cp $NEW $OLD
     50    UPDATE_ZONES="$UPDATE_ZONES $ZONE"
     51  fi
    4052done
    4153
Note: See TracChangeset for help on using the changeset viewer.