Skip to content

Instantly share code, notes, and snippets.

@cupracer
Last active January 26, 2018 10:07
Show Gist options
  • Save cupracer/7372d804740a5f9b4e83f5de65442467 to your computer and use it in GitHub Desktop.
Save cupracer/7372d804740a5f9b4e83f5de65442467 to your computer and use it in GitHub Desktop.
Update the timestamp of a Bind DNS zonefile
#!/bin/bash
if [ $# -ne 1 ]; then
echo "missing parameter"
exit 1
fi
ZONEFILE=$1
if ! [ -f $ZONEFILE ]; then
echo "$ZONEFILE does not exist"
exit 1
fi
echo updating $ZONEFILE
sed -i 's/[0-9]\{10\}.*serial$/'`date +%Y%m%d%H`' ; serial/g' $ZONEFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment