#!/bin/bash user=`whoami` if [ $user != "root" ]; then echo "You must be root to execute this" exit fi if [ -z "$1" ]; then echo "You must specify a zone file to update" exit fi _in_file="$1" echo "Finding serial in: $_in_file" _get_serial=`cat $_in_file | grep -i "serial" | cut -d ";" -f1` function parseserial { _get_serial=$1 } function incrementserial { _get_inc=`getincval $_get_serial` _date=`date +%Y%m%e$_get_inc` _get_serial=$(( $_date + 1 )) } parseserial $_get_serial _old_serial=$_get_serial echo "Serial Found: $_get_serial" echo "Incrementing serial by one" incrementserial $_get_serial echo "Serial incremented to: $_get_serial" # #- echo day | sed s/day/night/ # replaces day with night #- we need to: replace old with new # sed s// $_in_file-$_old_serial )" cp $_in_file $_in_file-$_old_serial echo "Replacing old serial ( $_old_serial ) with new serial ( $_get_serial ) and creating tmp file" sed s/$_old_serial/$_get_serial/ <$_in_file> $_in_file.tmp echo "Moving tmp file into primary location" mv $_in_file.tmp $_in_file #$2 = domain #$3 = type #$4 = type #$5 = IP #_parse_line="$2 $3 $4 $5" #echo _parse_line >> $_in_file