#!/bin/sh -e

# Author: Jonathan Riddell <jriddell@ubuntu.com>
# (C) 2006  Canonical Ltd.
#
# Get the status of Avahi daemon through exit code:
#
# 0: daemon is disabled (default configuration)
# 1: daemon is enabled for LAN
# 2: the configuration was adapted manually; in this case enable_avahi cannot
#    be used

CONF=/etc/default/avahi-daemon

[ -f $CONF ] || exit 2

if egrep -qi '^[[:space:]]*AVAHI_DAEMON_START=1[[:space:]]*(#.*)?$' $CONF; then
    exit 1
fi
if egrep -qi '^[[:space:]]*AVAHI_DAEMON_START=0[[:space:]]*(#.*)?$' $CONF; then
    exit 0
fi
exit 2
