From c83bef73d541b3cb8a242009ac9cf6f969536380 Mon Sep 17 00:00:00 2001
From: Zoran Dzelajlija <Zoran.Dzelajlija@CARNet.hr>
Date: Wed, 8 Nov 2006 12:58:19 +0000
Subject: [PATCH] r9: get_domain -> cp_get_mx_domain() (carnet-tools 2.7)

---
 debian/control   |    2 +-
 debian/postinst  |    2 +-
 src/functions.sh |   34 ----------------------------------
 3 files changed, 2 insertions(+), 36 deletions(-)

diff --git a/debian/control b/debian/control
index 3d71eb3..00b7cef 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.6.1
 Package: amavisd-cn
 Architecture: all
 Provides: amavisd-new-cn
-Depends: amavisd-new (>= 20030616p10-5), postfix | amavisd-new-milter (>= 20030616p10-5), postfix | sendmail (>= 8.13.1-20), clamav-cn (>= 0.80-7), spamassassin (>= 2.64), debianutils (>= 1.13.1), carnet-tools-cn (>= 2.1), procps, patch, host
+Depends: amavisd-new (>= 20030616p10-5), postfix | amavisd-new-milter (>= 20030616p10-5), postfix | sendmail (>= 8.13.1-20), clamav-cn (>= 0.80-7), spamassassin (>= 2.64), debianutils (>= 1.13.1), carnet-tools-cn (>= 2.7), procps, patch
 Pre-Depends: amavisd-new
 Recommends: sweep-cn, libsavi-perl
 Conflicts: libsavi-perl (<< 0.15), bunch-perl-modules-cn, sweep-cn (<< 1.8-2)
diff --git a/debian/postinst b/debian/postinst
index f3598f1..811121e 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -195,7 +195,7 @@ if cp_check_and_sed viruser s/viruser/clamav/ \
 fi # viruser
 
 # $domain will be equal to $host if nothing better can be found
-get_domain
+cp_get_mx_domain
 domain=$RET
 
 # sendmail config
diff --git a/src/functions.sh b/src/functions.sh
index a3b80f8..6363ac9 100644
--- a/src/functions.sh
+++ b/src/functions.sh
@@ -100,40 +100,6 @@ noisy_backup() {
   cp_echo "CN: Current configuration saved in /var/backups/`basename $1`.bak"
 }
 
-# if fqdn is name.dom3.dom2.dom1.hr, check if this host is MX for
-# either dom3.dom2.dom1.hr, dom2.dom1.hr or dom1.hr and dump highest level
-# domain on stdout
-get_domain() {
-  local domains d
-  RET=$host
-  if ! echo $host | grep -q '\.'; then
-    return
-  fi
-  if [ ! -x /usr/bin/host ]; then
-    cp_echo "CN: no host command... \$mydomain value might be unoptimal."
-    return
-  fi
-  domains=$(hostname -f | awk -F. '
-    {
-      for (i=2; i<NF; i++) { 
-        for (j=i; j<NF; j++) {
-          printf "%s", $(j)"."
-        };
-        print $NF
-      }
-    }'	  )
-  for d in $domains
-  do
-    mxes=$(host -t mx $d)
-    # handle output of both /usr/bin/host providers
-    mxes=$(echo "$mxes"|\
-           awk '/mail is handled by/ || /MX/ {print $NF}'|sed s/\.$//)
-    if echo "$mxes" |egrep -q "^$host$"; then
-      RET="$d"
-    fi
-  done
-}
-
 # XXX TODO implement per paragraph conditional munging some day
 in_paragraph() {
   return 1
-- 
1.7.10.4