#!/bin/sh

# 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
[ "$2" != "lo" ] || exit 0

# 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 ] ; then
  sudo -u avahi /usr/lib/avahi/avahi-daemon-check-dns.sh
fi

if test -f /etc/sysconfig/avahi ; then
  . /etc/sysconfig/avahi
fi

if test "$AVAHI_AUTOIPD_ENABLE" = "yes" ; then
  if test "$AVAHI_AUTOIPD_FORCE_BIND" = "yes" ; then
    FORCE=" --force-bind"
  else
    FORCE=""
  fi
  @sbindir@/avahi-autoipd -wD$FORCE $2 2> /dev/null || exit 0
fi
