]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add ENABLE_AVAHI env var to control dbus/avahi usage in container 2071/head
authorAdam Oleksy <adam.oleksy@gmail.com>
Mon, 22 Sep 2025 15:49:22 +0000 (17:49 +0200)
committerAdam Oleksy <adam.oleksy@gmail.com>
Mon, 22 Sep 2025 15:49:22 +0000 (17:49 +0200)
ENABLE_AVAHI decides whether dbus and avahi daemons run inside the
container or if the host's instances are reused. When set to 0,
/var/run/dbus and /var/run/avahi-daemon/socket must be bind-mounted
by the user from the host into the container.

docker/Dockerfile
docker/classic/Dockerfile
docker/classic/run.sh
docker/docker-compose.yaml
docker/run.sh

index f0680e9a651c135759de2b9265d00a8e0127e2f8..9b1347eb4f0a7123500b2bfd46bbec017bfcf9ab 100644 (file)
@@ -165,5 +165,5 @@ RUN apk -U add \
 # Added the shairport-sync user to the pre-existing audio group, which has ID 29, for access to the ALSA stuff
 
 COPY --from=files / /
-
+ENV ENABLE_AVAHI=1
 ENTRYPOINT ["./run.sh"]
index a7fd6b71be6ee296e26a803e085efcc3b2cc8bf0..5b7f96e8583cf5b3ca183078ce7c994351d8021a 100644 (file)
@@ -139,5 +139,5 @@ RUN apk --no-cache add \
 # Added the shairport-sync user to the pre-existing audio group, which has ID 29, for access to the ALSA stuff
 
 COPY --from=files / /
-
+ENV ENABLE_AVAHI=1
 ENTRYPOINT ["./run.sh"]
index 0303fa9b4095f564f262f7a2d2cbb4c1e20ec3aa..2d562bdb27063509034a641ad8dfce283e6e27c8 100755 (executable)
@@ -3,13 +3,14 @@
 # exist if any command returns a non-zero result
 set -e
 
-rm -rf /run/dbus/dbus.pid
-rm -rf /run/avahi-daemon/pid
+if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ]; then
+  rm -rf /run/dbus/dbus.pid
+  rm -rf /run/avahi-daemon/pid
 
 dbus-uuidgen --ensure
 dbus-daemon --system
 
-avahi-daemon --daemonize --no-chroot
+[ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ] || avahi-daemon --daemonize --no-chroot
 
 while [ ! -f /var/run/avahi-daemon/pid ]; do
   echo "Warning: avahi is not running, sleeping for 1 second before trying to start shairport-sync"
index 8a435bba89191fb2da7c58c0817c44bdc822f5c3..24d2f707c48163b193bdd1f49226185186d01952 100644 (file)
@@ -10,12 +10,15 @@ services:
     #  PULSE_SERVER: unix:/tmp/pulseaudio.socket # Path for PulseAudio socket
     #  PULSE_COOKIE: /tmp/pulseaudio.cookie # Path for PulseAudio cookie
     #  XDG_RUNTIME_DIR: /tmp # Path for pipewire
+    #  ENABLE_AVAHI: 0 # Disable DBus and Avahi daemon inside the container
     devices:
       - "/dev/snd" # ALSA device, omit if using PulseAudio
     # volumes:
     #   - ./volumes/shairport-sync/shairport-sync.conf:/etc/shairport-sync.conf # Customised Shairport Sync configuration file.
     #   - /run/user/1000/pulse/native:/tmp/pulseaudio.socket # PulseAudio socket when using that backend
     #   - /run/user/1000/pipewire-0:/tmp/pipewire-0 # Pipewire socket when using pipewire
+    #   - /var/run/dbus:/var/run/dbus # DBus when ENABLE_AVAHI set to 0
+    #   - /var/run/avahi-daemon:/var/run/avahi-daemon # Avahi socket when ENABLE_AVAHI set to 0
     # command: -o pw # You can specify the desired output with command:
     logging:
       options:
index b9caca726565aa3717e8852f171535fce5936fa2..3b656e9bdbd038f490e08c5ba236538ffe8c60e1 100755 (executable)
@@ -3,15 +3,17 @@
 # exist if any command returns a non-zero result
 set -e
 
-rm -rf /run/dbus/dbus.pid
-rm -rf /run/avahi-daemon/pid
+if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ]; then
+  rm -rf /run/dbus/dbus.pid
+  rm -rf /run/avahi-daemon/pid
 
-dbus-uuidgen --ensure
-dbus-daemon --system
+  dbus-uuidgen --ensure
+  dbus-daemon --system
+fi
 
 (/usr/local/bin/nqptp > /dev/null 2>&1) &
 
-avahi-daemon --daemonize --no-chroot
+[ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ] || avahi-daemon --daemonize --no-chroot
 
 while [ ! -f /var/run/avahi-daemon/pid ]; do
   echo "Warning: avahi is not running, sleeping for 1 second before trying to start shairport-sync"