Initial import into git

This commit is contained in:
2026-03-21 00:22:15 -06:00
commit 12c0fef463
9 changed files with 99 additions and 0 deletions

3
avahi-browse Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
set -eu
exec docker compose exec reflector avahi-browse "$@"

3
avahi-resolve Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
set -eu
exec docker compose exec reflector avahi-resolve "$@"

View File

@@ -0,0 +1,18 @@
services:
reflector:
build:
context: ./docker
container_name: "avahi-reflector"
pull_policy: build
restart: unless-stopped
network_mode: host
environment:
- "AVAHI_INTERFACES=dummy0"
# Ref: https://docs.docker.com/reference/dockerfile/#healthcheck
healthcheck:
test: ["CMD", "avahi-browse", "-a", "-c"]
interval: 1m30s
timeout: 30s
retries: 3
start_period: 5s
start_interval: 5s

20
docker/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
FROM alpine:latest
RUN apk --no-cache add \
avahi \
avahi-tools \
dbus \
envsubst \
s6-overlay \
socat
COPY ./services.d/ /etc/services.d/
COPY wait-for-dbus /usr/local/bin/
COPY avahi-daemon.conf.template /etc/avahi/
COPY entrypoint-dlitz.sh /
ENTRYPOINT ["/entrypoint-dlitz.sh"]
ENV AVAHI_INTERFACES=dummy0
#CMD ["/usr/sbin/avahi-daemon"]
CMD ["/bin/sh", "-c", "wait-for-dbus ; exec /usr/sbin/avahi-daemon"]

View File

@@ -0,0 +1,21 @@
# vim:set backupcopy=yes:
[server]
use-ipv4=yes
use-ipv6=yes
ratelimit-interval-usec=1000000
ratelimit-burst=1000
enable-dbus=yes
#allow-interfaces=br0,ve-wuuf-int
#allow-interfaces=br0,vlan-iot,ve-wuuf
#allow-interfaces=br0,ve-wuuf
allow-interfaces=${AVAHI_INTERFACES}
[publish]
disable-publishing=yes
[reflector]
enable-reflector=yes
#reflect-ipv=no
#reflect-filters=

4
docker/entrypoint-dlitz.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
set -eu
envsubst < /etc/avahi/avahi-daemon.conf.template > /etc/avahi/avahi-daemon.conf
exec /init "$@"

5
docker/services.d/dbus/run Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
set -eu
[ -f ./setup ] && source ./setup
#exec /usr/bin/dbus-daemon --system --nofork --nosyslog
exec /usr/bin/dbus-daemon --system --nofork

11
docker/services.d/dbus/setup Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
set -eu
mkdir -p /run/dbus
# Clean up stale pid file, if present.
pidfile=/run/dbus/dbus.pid
pid=$(cat "$pidfile" || true)
if [ -n "$pid" ] && ! [ -d "/proc/$pid" ]; then
echo >&2 "Removing stale PID file $pidfile"
rm -f "$pidfile"
fi

14
docker/wait-for-dbus Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
# dlitz 2025
set -eu
prog="$(basename "$0")"
socket=/run/dbus/system_bus_socket
for i in 1 2 3 4 5 6 7 8 9 10; do
if test -e "$socket" && socat -u stdio unix-connect:"$socket" </dev/null >/dev/null; then
echo >&2 "$prog: dbus socket connection successful: $socket"
exit 0
fi
echo >&2 "$prog: Could not connect to dbus socket $socket. Sleeping..."
sleep 1
done
echo >&2 "$prog: dbus socket connection failed: continuing anyway: $socket"