Codebase list avahi / 7fb53e7
* 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) git-svn-id: svn+ssh://svn.debian.org/svn/pkg-utopia/packages/unstable/avahi@1446 ceb527fc-18e6-0310-9fe2-813c157c29e7 Sjoerd Simons 17 years ago
4 changed file(s) with 125 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
11 #
22 # If we have an unicast .local domain, we immediately disable avahi to avoid
33 # conflicts with the multicast IP4LL .local domain
4 DISABLE_TAG_DIR="/var/run/avahi-daemon/"
5 DISABLE_TAG="$DISABLE_TAG_DIR/disabled-for-unicast-local"
4
5 RUNDIR="/var/run/avahi-daemon/"
6 DISABLE_TAG="$RUNDIR/disabled-for-unicast-local"
7 NS_CACHE="$RUNDIR/checked_nameservers"
68
79 AVAHI_DAEMON_DETECT_LOCAL=1
810
1214 exit 0
1315 fi
1416
17 ensure_rundir() {
18 if [ ! -d ${RUNDIR} ] ; then
19 mkdir -m 0755 -p ${RUNDIR}
20 chown avahi:avahi ${RUNDIR}
21 fi
22 }
1523
16 dns_has_local() {
17 # If there are no nameserver entries in resolv.conf there are no unicast
18 # .local domains :)
24 dns_reachable() {
25 # If there are no nameserver entries in resolv.conf there is no dns reachable
1926 $(grep -q nameserver /etc/resolv.conf) || return 1;
2027
2128 # If there is no local nameserver and no we have no global ip addresses
22 # then there is no need to query the nameservers
29 # then we can't reach any nameservers
2330 if ! $(egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf); then
2431 # Get addresses of all running interfaces
2532 ADDRS=$(LC_ALL=C ifconfig | grep ' addr:')
3037 fi
3138 fi
3239
40 return 0
41 }
42
43 dns_has_local() {
44 # Some magic to do tests
45 if [ -n ${FAKE_HOST_RETURN} ] ; then
46 if [ "${FAKE_HOST_RETURN}" = "true" ]; then
47 return 0;
48 else
49 return 1;
50 fi
51 fi
52
3353 OUT=`LC_ALL=C host -t soa local. 2>&1`
34 if [ $? -eq 0 ] && echo "$OUT" | egrep -vq 'has no|not found'; then
35 return 0
54 if [ $? -eq 0 ] ; then
55 if echo "$OUT" | egrep -vq 'has no|not found'; then
56 return 0
57 fi
58 else
59 # Checking the dns servers failed. Assuming no .local unicast dns, but
60 # remove the nameserver cache so we recheck the next time we're triggered
61 rm -f ${NS_CACHE}
3662 fi
3763 return 1
3864 }
3965
40 if dns_has_local ; then
41 if [ -x /etc/init.d/avahi-daemon ]; then
66 dns_needs_check() {
67 TMP_CACHE="${NS_CACHE}.$$"
68 RET=0
69
70 ensure_rundir
71 cat /etc/resolv.conf | grep "nameserver" | sort > ${TMP_CACHE} || return 0
72
73 if [ -e ${NS_CACHE} ]; then
74 DIFFERENCE=$(diff -w ${NS_CACHE} ${TMP_CACHE})
75 echo "${DIFFERENCE}" | grep -q '^>'
76 ADDED=$?
77 echo "${DIFFERENCE}" | grep -q '^<'
78 REMOVED=$?
79 echo "${DIFFERENCE}"
80 # Avahi was disabled and no servers were removed, no need to recheck
81 [ -e ${DISABLE_TAG} ] && [ ${REMOVED} -ne 0 ] && RET=1
82 # Avahi was enabled and no servers were added, no need to recheck
83 [ ! -e ${DISABLE_TAG} ] && [ ${ADDED} -ne 0 ] && RET=1
84 fi
85
86 mv ${TMP_CACHE} ${NS_CACHE}
87 return ${RET};
88 }
89
90
91 enable_avahi () {
92 # no unicast .local conflict, so remove the tag and start avahi again
93 if [ -e ${DISABLE_TAG} ]; then
94 rm -f ${DISABLE_TAG}
95 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
96 invoke-rc.d avahi-daemon start || true
97 else
98 if [ -x "/etc/init.d/avahi-daemon" ]; then
99 /etc/init.d/avahi-daemon start || true
100 fi
101 fi
102 fi
103 }
104
105 disable_avahi () {
106 [ -e ${DISABLE_TAG} ] && return
107
108 if [ -x /etc/init.d/avahi-daemon ]; then
109 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
110 invoke-rc.d --force avahi-daemon stop || true
111 else
112 if [ -x "/etc/init.d/avahi-daemon" ]; then
42113 /etc/init.d/avahi-daemon stop || true
43 if [ -x /usr/bin/logger ]; then
44 logger -p daemon.warning -t avahi <<EOF
114 fi
115 fi
116 if [ -x /usr/bin/logger ]; then
117 logger -p daemon.warning -t avahi <<EOF
45118 Avahi detected that your currently configured local DNS server serves
46119 a domain .local. This is inherently incompatible with Avahi and thus
47120 Avahi disabled itself. If you want to use Avahi in this network, please
49122 since .local should be used exclusively for Zeroconf technology.
50123 For more information, see http://avahi.org/wiki/AvahiAndUnicastDotLocal
51124 EOF
52 fi
53125 fi
54 if [ ! -d ${DISABLE_TAG_DIR} ] ; then
55 mkdir -m 0755 -p ${DISABLE_TAG_DIR}
56 chown avahi:avahi ${DISABLE_TAG_DIR}
57 fi
58 touch ${DISABLE_TAG}
126 fi
127 ensure_rundir
128 touch ${DISABLE_TAG}
129 }
130
131 if ! dns_reachable ; then
132 # No unicast dns server reachable, so enable avahi
133 enable_avahi
134 # And blow away the dns cache, so we force a recheck when the interface comes
135 # up again
136 rm -f ${NS_CACHE}
137 exit 0
138 fi
139
140 # Check if the dns needs checking..
141 dns_needs_check || exit 0
142
143 if dns_has_local ; then
144 # .local from dns server, disabling avahi
145 disable_avahi
59146 else
60 # no unicast .local conflict, so remove the tag and start avahi again
61 if [ -e ${DISABLE_TAG} ]; then
62 rm -f ${DISABLE_TAG}
63 if [ -x /etc/init.d/avahi-daemon ]; then
64 /etc/init.d/avahi-daemon start || true
65 fi
66 fi
147 # no .local from dns server, enablign avahi
148 enable_avahi
67149 fi
68150
69151 exit 0
11
22 # Don't run the avahi-daemon unicast local check while bringing up
33 # the loopback device; it's not necessary until we bring up a real network
4 # device, and we do those in the background so they don't hold up the
5 # boot process
4 # device
65 [ "$IFACE" != "lo" ] || exit 0
7
8 # If we have an unicast .local domain, we immediately disable avahi to avoid
9 # conflicts with the multicast IP4LL .local domain
106
117 # Bail out if resolvconf is installed
128 [ -x /sbin/resolvconf ] && exit 0
139
14 exec /usr/lib/avahi/avahi-daemon-check-dns.sh
10 # If we have an unicast .local domain, we immediately disable avahi to avoid
11 # conflicts with the multicast IP4LL .local domain
12 if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ]
13 exec /usr/lib/avahi/avahi-daemon-check-dns.sh
14 fi
22 # If we have an unicast .local domain, we immediately disable avahi to avoid
33 # conflicts with the multicast IP4LL .local domain
44
5 exec /usr/lib/avahi/avahi-daemon-check-dns.sh
5 if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ]
6 exec /usr/lib/avahi/avahi-daemon-check-dns.sh
7 fi
33 * debian/rules:
44 + Ensure that ServiceTypeDatabase.py is generated instead of using the one
55 from the tarball (Closes: #420184)
6 * debian/avahi-daemon-check-dns.sh:
7 + Minimise the number of times the DNS servers are checked for a unicast
8 .local domain even more. (Closes: #419796)
9 + Use invoke-rc.d to start/stop avahi as we're a proper sysv init service
10 now
11 * debian/avahi-daemon.{ifupdown,resolvconf}:
12 + Check if avahi-daemon-check-dns.sh is executable before executing it
13 (Closes: #419259)
614
715 [ Michael Biebl ]
816 * Start avahi-daemon and avahi-dnsconfd as regular SysV init scripts.
3846 + Update the Vcs control field from XS-X-Vcs-Svn to XS-Vcs-Svn.
3947 + Add XS-Vcs-Browser control field.
4048
41 -- Michael Biebl <biebl@debian.org> Fri, 27 Apr 2007 00:45:50 +0200
49 -- Sjoerd Simons <sjoerd@debian.org> Fri, 27 Apr 2007 11:48:45 +0200
4250
4351 avahi (0.6.18-3) unstable; urgency=low
4452