What the hell, I was bored:

#!/bin/sh
#####################################################
# gdipnsupd.sh
#
# This is a sample script showing how to intercept the
# call GnuDIP makes to "nsupdate" in order to take
# additonal actions.
#
# Use this script as the value for the "nsupdate"
# parameter in "gnudip.conf". The actual nsupdate
# command should be passed as the arguments to this
# script. So the name of this script just gets inserted
# in front of the nsupdate command.
#
#####################################################

# the real nsupdate command
nsupdate="$*"

# process one line of input
function process_line() {
  # process the line of input
  logger -t gdipnsupd.sh $REPLY
  if [ "$2" == 'add' ] && [ "$5" == 'A' ]
  then
    logger -t gdipnsupd.sh IP address for $3 set to $6
  elif [ "$2" == 'delete' ] && [ "$4" == 'A' ]
  then
    logger -t gdipnsupd.sh IP address for $3 removed
  fi
}

# read, log and save
intext=
while read
do
  intext="$intext$REPLY\n"
  process_line $REPLY
done

# run nsupdate
echo -e "$intext" | command $nsupdate
retc=$?

exit $retc

This works with "bash" on Linux.

If anybody thinks this is a helpful example I will stick it in the
"sbin" directory.

Creighton MacDonnell wrote:
> 
> The only thing I can suggest, other than modifying the GnuDIP code, is
> to specify a script of your own for the "nsupdate" parameter in
> "gnudip.conf".
> 
> This script (which can just be a shell script - no need for Perl) would
> have to parse the input for nsupdate, then pass the same input to the
> real nsupdate command, and then depending on what it found from the
> parsing, do whatever else needs to be done.
> 
> The input that GnuDIP generates for nsupdate is pretty simple. First try
> writing a script that just grabs and logs the input using "logger", and
> then calls the real nsupdate. Then add what you need.
> 
> Or perhaps someone else on this list would like to provide this as a
> starting point?
> 
> How about posting this to the list afterwards? I think this general
> technique could have many uses. I'll put it on the site somewhere.
> 

-- 
Creighton MacDonnell
http://macdonnell.ca/


-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
--
GnuDIP Mailing List
http://gnudip2.sourceforge.net/gnudip-www/#mailinglist

Reply via email to