--- /dev/null
+This program let you edit dynamic dns zones like standard zones. Here is the
+process used when you call this program:
+
+- ddnsedit query the server for the specified zone
+- ddnsedit run $EDITOR on a copy of the zone
+- you make your changes on the zone, then save and quit the editor like on a
+ standard zone
+- ddnsedit presents you a summary of your changes and ask you to confirm your
+ update
+- on confirm, it runs the needed nsupdate commands to update the zone
+
+It is released under the GNU GPL (see copyright for more details).
+
+Requirements:
+------------
+You need to have the following programs installed along with a dns server with
+a zone configured for dynamic updates and that allows the computer where you
+run ddnsedit to do the update and to transfer the zone.
+
+- bash
+- mktemp
+- nsupdate
+- dig
+- diff
+- cat
+
+Installation:
+------------
+
+Put ddnsedit in your PATH (/usr/local/bin for example).
+
+Usage:
+-----
+
+Just run "ddnsedit" without options to get help.
+
--- /dev/null
+Copyright (C) 2008 Emmanuel Lacour <elacour@home-dn.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+ USA.
--- /dev/null
+#!/bin/bash
+#
+# Name: ddnsedit
+# Description: Edit a dynamic dns zone with an editor, then update it by
+# calling "nsupdate"
+#
+# Copyright (C) 2008 Emmanuel Lacour <elacour@home-dn.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+
+
+SERVER=$1
+ZONE=$2
+
+
+function usage {
+ echo "Usage: `basename $0` SERVER ZONE_NAME"
+ exit 0
+}
+
+if [ ! -n "$ZONE" ]
+then
+ echo "Missing zone name!"
+ usage
+fi
+
+if [ ! -n "$SERVER" ]
+then
+ echo "Missing server!"
+ usage
+fi
+
+
+# Cleanup zone name
+if [ `echo "$ZONE" | grep -c '\.$'` -eq 0 ]
+then
+ ZONE="$ZONE."
+fi
+
+FILE_O=`mktemp /tmp/nsedit_o.XXXXXX`
+FILE_N=`mktemp /tmp/nsedit_n.XXXXXX`
+FILE_D=`mktemp /tmp/nsedit_d.XXXXXX`
+FILE_U=`mktemp /tmp/nsedit_u.XXXXXX`
+FILE_ERR=`mktemp /tmp/nsedit_err.XXXXXX`
+
+# Get the current zone
+# (skip SOA wich cannot be updated by nsupdate)
+dig @$SERVER $ZONE AXFR | grep -Ev '^;|^$' | grep -v 'IN SOA ' > $FILE_O
+
+# Duplicate the zone
+cat $FILE_O > $FILE_N
+
+function main {
+ # Edit the zone
+ $EDITOR $FILE_N
+
+ # Diff between old and new file
+ diff -au $FILE_O $FILE_N | grep -E '^-|^\+' | grep -Ev '^--- |^\+\+\+ ' > $FILE_D
+
+ if [ ! -s $FILE_D ]
+ then
+ echo "Empty changes, exiting!"
+ exit 0
+ fi
+
+ # Prepare nsupdate file
+ echo "server $SERVER" > $FILE_U
+ # Diff between zones
+ sed 's/^-/update delete /g;s/^+/update add /g' $FILE_D >> $FILE_U
+ echo 'send' >> $FILE_U
+
+ echo "Do you really wan't to send the following updates?"
+ cat $FILE_U
+ echo -n "Answer (y/n):"
+ read a
+
+ if [ "$a" == "y" ]
+ then
+ nsupdate $FILE_U > $FILE_ERR 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "Update failed: "
+ cat $FILE_ERR
+ echo -n "Do you wan't to edit back you're file (y/n): "
+ read a
+ if [ "$a" == "y" ]
+ then
+ main
+ else
+ echo "Ok, exiting..."
+ fi
+ else
+ echo "Update succeded!"
+ cat $FILE_ERR
+ fi
+ else
+ echo "Ok, exiting..."
+ fi
+}
+
+main
+
+rm -f $FILE_O $FILE_N $FILE_D $FILE_U $FILE_ERR