- update dokumentacije
[bind9-cn.git] / debian / postinst
index 567dedf..1a30795 100755 (executable)
@@ -31,7 +31,7 @@ esac
 . /usr/share/carnet-tools/functions.sh
 
 echo "CN: Making sample configurations in /usr/share/doc/bind9-cn/examples"
-echo "CN: Make sure you read them and apply *before* running Bind9 service!"
+echo "CN: Make sure you change them appropriately *before* running Bind9 service!"
 
 #variables
 cp_get_ifaddr
@@ -73,7 +73,6 @@ acl "trusted" {
 
 options {
     directory "/etc/bind";
-    query-source address * port 53;
     auth-nxdomain no;
     allow-transfer { xfer; };
     allow-recursion { trusted; };
@@ -150,17 +149,40 @@ nameserver 161.53.2.70
 EOF
 
 # check if named.conf has lame server logging
-if [ -e /etc/bind/named.conf.options ]; then
-  lameconf=$(awk '/^logging/,/^}/ { if ($0 ~ /category lame-servers/) { print "yes"; exit } }' /etc/bind/named.conf)
-  if [ "x$lameconf" != "xyes" ]; then
-    cp /etc/bind/named.conf.options /etc/bind/named.conf.options.$$
-    cp-update bind9-cn /etc/bind/named.conf.options.$$ <<EOF
+script='/^logging/,/^}/ { if ($0 ~ /category lame-servers/) { print "yes"; exit } }'
+lameconf=
+if [ -e /etc/bind/named.conf.options -a -e /etc/bind/named.conf ]; then
+  lameconf=$(cat /etc/bind/named.conf /etc/bind/named.conf.options | awk "$script")
+else
+    if [ -e /etc/bind/named.conf ]; then
+      lameconf=$(awk "$script" /etc/bind/named.conf)
+    fi
+fi
+if [ "x$lameconf" != "xyes" ]; then
+  if [ ! -e /etc/bind/named.conf.options ]; then
+    touch /etc/bind/named.conf.options
+  fi
+  cp /etc/bind/named.conf.options /etc/bind/named.conf.options.$$
+  cp-update bind9-cn /etc/bind/named.conf.options.$$ <<EOF
 logging {
     category lame-servers { null; };
 };
 EOF
+  cp_mv /etc/bind/named.conf.options.$$ /etc/bind/named.conf.options
+    
+  # reload
+  echo "CN: Added lame-servers logging exclusion to named.conf.options"
+  rndc reload || echo "CN: Reload didn't work, please check manually"
+fi
+
+if [ -e /etc/bind/named.conf.options ] && \
+    fgrep -q 'query-source address * port 53' \
+        /etc/bind/named.conf.options; then
+        fgrep -v 'query-source address * port 53' \
+            /etc/bind/named.conf.options > /etc/bind/named.conf.options.$$
     cp_mv /etc/bind/named.conf.options.$$ /etc/bind/named.conf.options
-  fi
+    echo "CN: Removing obsolete query-source directive"
+    rndc reload || echo "CN: Reload didn't work, please check manually"
 fi
 
 # dh_installdeb will replace this with shell code automatically