#!/usr/bin/env bash #_zone_files_dir=/etc/bind/master _zone_files_dir=/root/tmp/master _comment=";; - IPv6 disabled " cp -a $_zone_files_dir ${_zone_files_dir}.BAK-`date +%Y-%m-%d-%H%M` __zonefiles=`grep -l -E "^${_comment}.*\s*AAAA" ${_zone_files_dir}/*.zone` for zone_file in $__zonefiles ; do _serial_new=`date +%Y%m%d01` echo -e "\tconverting $zone_file .." _replaced=false ## - calculate new serial ## - declare -i __serial=`grep -e "[0-9]\{10\}" $zone_file | grep serial | awk '{print$1}'` while [ ! $_serial_new -gt $__serial ]; do let _serial_new++ done perl -i -n -p -e "s/^${_comment}(.*\s+AAAA\s+.*)$/\1/" $zone_file if [ $? -eq 0 ]; then _replaced=true fi ## - setze neue serial ## - if $_replaced ; then perl -i -n -p -e "s#^(\s*)\s$__serial(.*)#\1 $_serial_new\2#" $zone_file fi done exit