Op 20-02-17 om 11:55 schreef John Allen:
> Is the process to update the serial number automatic? If so care to share.


Just a tiny and unreliable script that works in my controlled
environment where zonefiles use a serial based on the date. I wouldn't
recommend using it as is, but I've attached it for inspiration.


-- 
Casper Gielen <[email protected]> | LIS UNIX
PGP fingerprint = 16BD 2C9F 8156 C242 F981  63B8 2214 083C F80E 4AF7

Universiteit van Tilburg | Postbus 90153, 5000 LE
Warandelaan 2 | Telefoon 013 466 4100 | G 236 | http://www.uvt.nl


#!/usr/bin/env bash
#
# Update serial in a zone file
# Casper Gielen, 2016

usage() {
        echo "usage: update-serial <zonefile>"
        echo "Updates the serial of a zonefile to the current date + a counter"
        exit 1
}

zonefile="$1"
[ -z "$zonefile" ] && usage

# FIXME: improve the way we find the serial
old=$(awk '/;serial/{print $1}' $zonefile)
old_date=${old:0:8}
old_count=${old:(-2)}
new_date=$(date +%Y%m%d)
new_count="00"
if [ "$new_date" == "$old_date" ]; then
        new_count=$(printf "%02d" "$[ 10#$old_count + 1 ]")
fi
new="${new_date}${new_count}"
# FIXME: make sure we change the right line
sed -i "s/$old/$new/" $zonefile

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to