[Pkg-utopia-commits] r1446 - in /packages/unstable/avahi/debian:
avahi-daemon-check-dns.sh
avahi-daemon.ifupdown avahi-daemon.resolvconf changelog
sjoerd at users.alioth.debian.org
sjoerd at users.alioth.debian.org
Fri Apr 27 09:59:49 UTC 2007
Author: sjoerd
Date: Fri Apr 27 09:59:49 2007
New Revision: 1446
URL: http://svn.debian.org/wsvn/pkg-utopia/?sc=1&rev=1446
Log:
* debian/avahi-daemon-check-dns.sh:
+ Minimise the number of times the DNS servers are checked for a unicast
.local domain even more. (Closes: #419796)
+ Use invoke-rc.d to start/stop avahi as we're a proper sysv init service
now
* debian/avahi-daemon.{ifupdown,resolvconf}:
+ Check if avahi-daemon-check-dns.sh is executable before executing it
(Closes: #419259)
Modified:
packages/unstable/avahi/debian/avahi-daemon-check-dns.sh
packages/unstable/avahi/debian/avahi-daemon.ifupdown
packages/unstable/avahi/debian/avahi-daemon.resolvconf
packages/unstable/avahi/debian/changelog
Modified: packages/unstable/avahi/debian/avahi-daemon-check-dns.sh
URL: http://svn.debian.org/wsvn/pkg-utopia/packages/unstable/avahi/debian/avahi-daemon-check-dns.sh?rev=1446&op=diff
==============================================================================
--- packages/unstable/avahi/debian/avahi-daemon-check-dns.sh (original)
+++ packages/unstable/avahi/debian/avahi-daemon-check-dns.sh Fri Apr 27 09:59:49 2007
@@ -2,8 +2,10 @@
#
# If we have an unicast .local domain, we immediately disable avahi to avoid
# conflicts with the multicast IP4LL .local domain
-DISABLE_TAG_DIR="/var/run/avahi-daemon/"
-DISABLE_TAG="$DISABLE_TAG_DIR/disabled-for-unicast-local"
+
+RUNDIR="/var/run/avahi-daemon/"
+DISABLE_TAG="$RUNDIR/disabled-for-unicast-local"
+NS_CACHE="$RUNDIR/checked_nameservers"
AVAHI_DAEMON_DETECT_LOCAL=1
@@ -13,14 +15,19 @@
exit 0
fi
+ensure_rundir() {
+ if [ ! -d ${RUNDIR} ] ; then
+ mkdir -m 0755 -p ${RUNDIR}
+ chown avahi:avahi ${RUNDIR}
+ fi
+}
-dns_has_local() {
- # If there are no nameserver entries in resolv.conf there are no unicast
- # .local domains :)
+dns_reachable() {
+ # If there are no nameserver entries in resolv.conf there is no dns reachable
$(grep -q nameserver /etc/resolv.conf) || return 1;
# If there is no local nameserver and no we have no global ip addresses
- # then there is no need to query the nameservers
+ # then we can't reach any nameservers
if ! $(egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf); then
# Get addresses of all running interfaces
ADDRS=$(LC_ALL=C ifconfig | grep ' addr:')
@@ -31,18 +38,84 @@
fi
fi
+ return 0
+}
+
+dns_has_local() {
+ # Some magic to do tests
+ if [ -n ${FAKE_HOST_RETURN} ] ; then
+ if [ "${FAKE_HOST_RETURN}" = "true" ]; then
+ return 0;
+ else
+ return 1;
+ fi
+ fi
+
OUT=`LC_ALL=C host -t soa local. 2>&1`
- if [ $? -eq 0 ] && echo "$OUT" | egrep -vq 'has no|not found'; then
- return 0
+ if [ $? -eq 0 ] ; then
+ if echo "$OUT" | egrep -vq 'has no|not found'; then
+ return 0
+ fi
+ else
+ # Checking the dns servers failed. Assuming no .local unicast dns, but
+ # remove the nameserver cache so we recheck the next time we're triggered
+ rm -f ${NS_CACHE}
fi
return 1
}
-if dns_has_local ; then
- if [ -x /etc/init.d/avahi-daemon ]; then
+dns_needs_check() {
+ TMP_CACHE="${NS_CACHE}.$$"
+ RET=0
+
+ ensure_rundir
+ cat /etc/resolv.conf | grep "nameserver" | sort > ${TMP_CACHE} || return 0
+
+ if [ -e ${NS_CACHE} ]; then
+ DIFFERENCE=$(diff -w ${NS_CACHE} ${TMP_CACHE})
+ echo "${DIFFERENCE}" | grep -q '^>'
+ ADDED=$?
+ echo "${DIFFERENCE}" | grep -q '^<'
+ REMOVED=$?
+ echo "${DIFFERENCE}"
+ # Avahi was disabled and no servers were removed, no need to recheck
+ [ -e ${DISABLE_TAG} ] && [ ${REMOVED} -ne 0 ] && RET=1
+ # Avahi was enabled and no servers were added, no need to recheck
+ [ ! -e ${DISABLE_TAG} ] && [ ${ADDED} -ne 0 ] && RET=1
+ fi
+
+ mv ${TMP_CACHE} ${NS_CACHE}
+ return ${RET};
+}
+
+
+enable_avahi () {
+ # no unicast .local conflict, so remove the tag and start avahi again
+ if [ -e ${DISABLE_TAG} ]; then
+ rm -f ${DISABLE_TAG}
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d avahi-daemon start || true
+ else
+ if [ -x "/etc/init.d/avahi-daemon" ]; then
+ /etc/init.d/avahi-daemon start || true
+ fi
+ fi
+ fi
+}
+
+disable_avahi () {
+ [ -e ${DISABLE_TAG} ] && return
+
+ if [ -x /etc/init.d/avahi-daemon ]; then
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d --force avahi-daemon stop || true
+ else
+ if [ -x "/etc/init.d/avahi-daemon" ]; then
/etc/init.d/avahi-daemon stop || true
- if [ -x /usr/bin/logger ]; then
- logger -p daemon.warning -t avahi <<EOF
+ fi
+ fi
+ if [ -x /usr/bin/logger ]; then
+ logger -p daemon.warning -t avahi <<EOF
Avahi detected that your currently configured local DNS server serves
a domain .local. This is inherently incompatible with Avahi and thus
Avahi disabled itself. If you want to use Avahi in this network, please
@@ -50,21 +123,30 @@
since .local should be used exclusively for Zeroconf technology.
For more information, see http://avahi.org/wiki/AvahiAndUnicastDotLocal
EOF
- fi
fi
- if [ ! -d ${DISABLE_TAG_DIR} ] ; then
- mkdir -m 0755 -p ${DISABLE_TAG_DIR}
- chown avahi:avahi ${DISABLE_TAG_DIR}
- fi
- touch ${DISABLE_TAG}
+ fi
+ ensure_rundir
+ touch ${DISABLE_TAG}
+}
+
+if ! dns_reachable ; then
+ # No unicast dns server reachable, so enable avahi
+ enable_avahi
+ # And blow away the dns cache, so we force a recheck when the interface comes
+ # up again
+ rm -f ${NS_CACHE}
+ exit 0
+fi
+
+# Check if the dns needs checking..
+dns_needs_check || exit 0
+
+if dns_has_local ; then
+ # .local from dns server, disabling avahi
+ disable_avahi
else
- # no unicast .local conflict, so remove the tag and start avahi again
- if [ -e ${DISABLE_TAG} ]; then
- rm -f ${DISABLE_TAG}
- if [ -x /etc/init.d/avahi-daemon ]; then
- /etc/init.d/avahi-daemon start || true
- fi
- fi
+ # no .local from dns server, enablign avahi
+ enable_avahi
fi
exit 0
Modified: packages/unstable/avahi/debian/avahi-daemon.ifupdown
URL: http://svn.debian.org/wsvn/pkg-utopia/packages/unstable/avahi/debian/avahi-daemon.ifupdown?rev=1446&op=diff
==============================================================================
--- packages/unstable/avahi/debian/avahi-daemon.ifupdown (original)
+++ packages/unstable/avahi/debian/avahi-daemon.ifupdown Fri Apr 27 09:59:49 2007
@@ -2,14 +2,14 @@
# Don't run the avahi-daemon unicast local check while bringing up
# the loopback device; it's not necessary until we bring up a real network
-# device, and we do those in the background so they don't hold up the
-# boot process
+# device
[ "$IFACE" != "lo" ] || exit 0
-
-# If we have an unicast .local domain, we immediately disable avahi to avoid
-# conflicts with the multicast IP4LL .local domain
# Bail out if resolvconf is installed
[ -x /sbin/resolvconf ] && exit 0
-exec /usr/lib/avahi/avahi-daemon-check-dns.sh
+# If we have an unicast .local domain, we immediately disable avahi to avoid
+# conflicts with the multicast IP4LL .local domain
+if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ]
+ exec /usr/lib/avahi/avahi-daemon-check-dns.sh
+fi
Modified: packages/unstable/avahi/debian/avahi-daemon.resolvconf
URL: http://svn.debian.org/wsvn/pkg-utopia/packages/unstable/avahi/debian/avahi-daemon.resolvconf?rev=1446&op=diff
==============================================================================
--- packages/unstable/avahi/debian/avahi-daemon.resolvconf (original)
+++ packages/unstable/avahi/debian/avahi-daemon.resolvconf Fri Apr 27 09:59:49 2007
@@ -3,4 +3,6 @@
# If we have an unicast .local domain, we immediately disable avahi to avoid
# conflicts with the multicast IP4LL .local domain
-exec /usr/lib/avahi/avahi-daemon-check-dns.sh
+if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ]
+ exec /usr/lib/avahi/avahi-daemon-check-dns.sh
+fi
Modified: packages/unstable/avahi/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-utopia/packages/unstable/avahi/debian/changelog?rev=1446&op=diff
==============================================================================
--- packages/unstable/avahi/debian/changelog (original)
+++ packages/unstable/avahi/debian/changelog Fri Apr 27 09:59:49 2007
@@ -4,6 +4,14 @@
* debian/rules:
+ Ensure that ServiceTypeDatabase.py is generated instead of using the one
from the tarball (Closes: #420184)
+ * debian/avahi-daemon-check-dns.sh:
+ + Minimise the number of times the DNS servers are checked for a unicast
+ .local domain even more. (Closes: #419796)
+ + Use invoke-rc.d to start/stop avahi as we're a proper sysv init service
+ now
+ * debian/avahi-daemon.{ifupdown,resolvconf}:
+ + Check if avahi-daemon-check-dns.sh is executable before executing it
+ (Closes: #419259)
[ Michael Biebl ]
* Start avahi-daemon and avahi-dnsconfd as regular SysV init scripts.
@@ -39,7 +47,7 @@
+ Update the Vcs control field from XS-X-Vcs-Svn to XS-Vcs-Svn.
+ Add XS-Vcs-Browser control field.
- -- Michael Biebl <biebl at debian.org> Fri, 27 Apr 2007 00:45:50 +0200
+ -- Sjoerd Simons <sjoerd at debian.org> Fri, 27 Apr 2007 11:48:45 +0200
avahi (0.6.18-3) unstable; urgency=low
More information about the Pkg-utopia-commits
mailing list