#!/bin/bash # # zonefile_to_tinydns, converts one BIND-format zone file to # tinydns-data format. # # Copyright Michael Orlitzky # # http://michael.orlitzky.com/ # # Released under the WTFPLv2. # # http://sam.zoy.org/wtfpl/COPYING # # What it Does # # This script converts one BIND zonefile to tinydns-data format. # Read the usage description below for input/output format. # # There's only one bit of configuration you need to do: enter the path # to the bind-to-tinydns program below. BIND_TO_TINYDNS=~/bind-to-tinydns-0.4.3/bind-to-tinydns # Leave the rest alone unless you don't want to. EXIT_SUCCESS=0 EXIT_NOT_ENOUGH_ARGS=1 if [ $# -lt 1 ]; then echo 'Usage:' echo '' echo " $0 [extension]" echo '' echo 'The input file should be of the form .something, where' echo 'the extension is arbitrary but required. The output file will be' echo 'named .extension if the optional extension argument is' echo 'supplied. The default extension is "tinydns".' echo '' echo 'Example:' echo '' echo " $0 example.org.dns" echo '' echo 'would output a tinydns-data file named example.org.tinydns.' echo '' exit $EXIT_NOT_ENOUGH_ARGS fi # Set the default extension. OUT_EXTENSION='tinydns' if [ $# -gt 1 ]; then # The user supplied an extension. Use it. OUT_EXTENSION=$2 fi # If the input file name does not contain both a zone and an # extension, terrible things are going to happen here. INFILE=`basename $1` ZONE="${INFILE%.*}" OUTFILE="${ZONE}.${OUT_EXTENSION}" TMPFILE="${ZONE}.tmp" $BIND_TO_TINYDNS $ZONE $OUTFILE $TMPFILE < $1 exit $EXIT_SUCCESS