Changeset 174


Ignore:
Timestamp:
02/19/2007 10:13:02 PM (5 years ago)
Author:
Ernest0x
Message:
  • Added validity check for the current zone file
  • Added timestamps in error messages
  • Print named-checkzone output if errors occured
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/zone_update/zone_update

    r139 r174  
    11#!/bin/bash 
    2 # zone_update bash script Version 0.7 
     2# zone_update bash script Version 0.8 
    33# Copyleft 2005 - Ernest0x (ernest0x at yahoo dot gr) 
    44 
     
    1212# Notes 
    1313# ----- 
    14 # - The php-generated zone file must include a line that contains a "; serial" substring.  
    15 #   This line gives its place to a new serial line, constructed by this script. 
    16 # --------------------------------------------------------------------------------------- # 
     14# - Both your system's zone file and the php-generated zone file must include a  
     15#   line that contains a "; serial" comment string. This line gives its place to  
     16#   a new serial line, constructed by this script. 
    1717 
    1818 
     
    4141   exit 
    4242fi 
     43 
     44# Check the syntax of the current zone file and make sure it includes "; serial" line 
     45if ! ( named-checkzone -q $CUR_ZONE $ZONES_ROOT$CUR_ZONE && grep -q "; serial" $ZONES_ROOT$CUR_ZONE ) ; then 
     46   echo "`date` - $ZONES_ROOT$CUR_ZONE has errors (wrong syntax or  missing '; serial' comment)." 
     47   echo "#### START of named-checkzone output (if OK then '; serial' comment is missing) ####" 
     48   echo "`named-checkzone $CUR_ZONE $ZONES_ROOT$CUR_ZONE`" 
     49   echo "#### END of named-checkzone output ####" 
     50   exit 
     51fi 
    4352  
    4453# Where we will temporarily save the php-generated zone file. 
     
    5261 
    5362# Make PHP_ZONE 
     63cd `dirname $PHP_SCRIPT` 
    5464php $PHP_SCRIPT $CUR_ZONE > $PHP_ZONE 
    5565 
     
    5767# Remember to change '2' to '3' on the next millenium change. :P 
    5868CUR_SERIAL=`grep "; serial" $ZONES_ROOT$CUR_ZONE | grep -o "2........."` 
     69 
     70# Check the validity of CUR_SERIAL 
     71CUR_SERIAL_CHARS=`echo -n $CUR_SERIAL | wc -m` 
     72if [ $CUR_SERIAL_CHARS -ne 10 ] || ! date -d `echo $CUR_SERIAL | cut -c 1-8` > /dev/null 2>&1 ; then 
     73    echo "`date` - Serial line in $ZONES_ROOT$CUR_ZONE is not valid." 
     74    exit 
     75fi 
    5976 
    6077# Day Of CUR_SERIAL 
     
    118135     mv -f /tmp/$CUR_ZONE $ZONES_ROOT 
    119136  else 
    120      echo "PHP-generated file has errors (possible database failure)" 
     137     echo "`date` - PHP-generated file has errors (possible database failure)" 
     138     echo "#### START of named-checkzone output ####" 
     139     echo "`named-checkzone $CUR_ZONE /tmp/$CUR_ZONE`" 
     140     echo "#### END of named-checkzone output ####" 
    121141     rm -f $PHP_ZONE $CUR_ZONE_S $PHP_ZONE_S /tmp/$CUR_ZONE 
    122142     exit 
Note: See TracChangeset for help on using the changeset viewer.