#!/usr/bin/execlineb -P
# avahi-daemon in foreground (no -D); unicast-.local gate like OpenRC.

envfile -I /etc/default/avahi-daemon
importas -uD "1" AVAHI_DAEMON_DETECT_LOCAL AVAHI_DAEMON_DETECT_LOCAL
envfile -I /etc/s6-rc/config/avahi-daemon.conf
importas -sCuD "" Args Args

ifelse {
	ifelse { test -e /var/run/avahi-daemon/disabled-for-unicast-local } {
		# Tag present: pause unless detect-local disabled
		ifelse { test "${AVAHI_DAEMON_DETECT_LOCAL}" = 0 } { true } { exit 1 }
	} { true }
} {
	fdmove -c 2 1
	exec /usr/sbin/avahi-daemon ${Args}
}
s6-pause
