Package: maradns
Severity: wishlist
Tags: patch

Please consider installing the attached file to
/etc/resolvconf/update.d/maradns to enable non-intrusive updating of
upstream_servers when resolvconf gets new addresses.

Cheers,

-- 
 .''`.     martin f. krafft <[EMAIL PROTECTED]>
: :'  :    proud Debian developer and author: http://debiansystem.info
`. `'`
  `-  Debian - when you have better things to do than fixing a system
 
Invalid/expired PGP (sub)keys? Use subkeys.pgp.net as keyserver!
 
"i sometimes think that god
 in creating man
 somewhat overestimated his ability."
                                                        -- oscar wilde
#!/bin/bash -e
#
# Script to update the maradns upstream server list
#
# Resolvconf may run even if maradns is not running. In that case, we update
# update the configuration file but do not restart the daemon.
# Otherwise, maradns is only restarted if the configuration file changed.
#
# If you want to use this script, set your upstream_servers["."] variable to
# "resolvconf_nameservers" (see $IPV4_ALIAS value below)
IPV4_ALIAS=resolvconf_nameservers
# E.g.: upstream_servers["."] = "resolvconf_nameservers"
#
# This only works with the main maradns server, using configuration file
# /etc/maradns/mararc. Patches to extend this functionality to multiple servers
# are welcome.
#
# (c) 2006 Martin F. Krafft <[EMAIL PROTECTED]>
# Released under the terms of the Artistic Licence.
#

PATH=/usr/sbin:/usr/bin:/sbin:/bin

# fail silently if resolvconf is not installed.
LISTRECS=/lib/resolvconf/list-records
[ -x $LISTRECS ] || exit 0
IFACEDIR=/etc/resolvconf/run/interface
[ -d $IFACEDIR ] || exit 0

MARARC=/etc/maradns/mararc
[ -e $MARARC ] || exit 0
[ -w $MARARC ] || exit 1

cd $IFACEDIR
RECORDS=$(/lib/resolvconf/list-records)
if [ -n "$RECORDS" ]; then
  IPS=$(sed -ne 's,^nameserver ,,p' $RECORDS)
  for ip in $IPS; do
    ifconfig -a | grep -q " inet addr:${ip//./\.}" || CSL=${CSL}${CSL:+,}$ip
  done
fi

[ -n "$CSL" ] || exit 0

IPV4ALIAS_REGEXP="ipv4_alias\[\"$IPV4_ALIAS\"\]"

CHANGED=0
if grep -q $IPV4ALIAS_REGEXP $MARARC; then

  HASHSUM=$(md5sum $MARARC)
  SEDSCRIPT="[EMAIL PROTECTED]($IPV4ALIAS_REGEXP\)[[:space:[EMAIL PROTECTED] = 
\"$CSL\"@"
  sed -i -e "$SEDSCRIPT" $MARARC
  [ "$HASHSUM" != "$(md5sum $MARARC)" ] && CHANGED=1

else

  echo "${IPV4ALIAS_REGEXP//\\\\/} = \"$CSL\"" >> $MARARC
  CHANGED=1

fi
  
MARAINIT=/etc/init.d/maradns
if [ -x $MARAINIT ] && [ $CHANGED -eq 1 ]; then
  ps -fC maradns | grep -q $MARARC && exec $MARAINIT restart
fi

exit 0

Attachment: signature.asc
Description: Digital signature (GPG/PGP)

Reply via email to