Skip to content

Commit

Permalink
improve management of avahi
Browse files Browse the repository at this point in the history
  • Loading branch information
Dignabbit committed Jul 9, 2023
1 parent ce138d1 commit fac112f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
6 changes: 6 additions & 0 deletions install/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ services:
# Uncomment next 3 lines for Nvidia GPU support.
# - NVIDIA_VISIBLE_DEVICES=all
# - NVIDIA_DRIVER_CAPABILITIES=all

# Uncomment next line to run avahi-daemon inside the container
# Don't use if dbus and avahi run on the host and are bind-mounted
# (see below under "volumes")
# - SCRYPTED_DOCKER_AVAHI=true
# runtime: nvidia

volumes:
Expand All @@ -56,6 +61,7 @@ services:

# uncomment the following lines to expose Avahi, an mDNS advertiser.
# make sure Avahi is running on the host machine, otherwise this will not work.
# not compatible with Avahi enabled via SCRYPTED_DOCKER_AVAHI=true
# - /var/run/dbus:/var/run/dbus
# - /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket

Expand Down
6 changes: 3 additions & 3 deletions install/docker/fs/etc/s6-overlay/s6-rc.d/avahi/run
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ -z "$SCRYPTED_DOCKER_AVAHI" ]
then
if [[ "${SCRYPTED_DOCKER_AVAHI}" != "true" ]]; then
echo "SCRYPTED_DOCKER_AVAHI != true, not starting avahi-daemon" >/dev/stderr
while true
do
sleep 1000
Expand All @@ -13,4 +13,4 @@ until [ -e /var/run/dbus/system_bus_socket ]; do
sleep 1s
done
echo "Starting Avahi daemon..."
exec avahi-daemon --no-chroot -f /etc/avahi/avahi-daemon.conf
exec avahi-daemon --no-chroot -f /etc/avahi/avahi-daemon.conf
10 changes: 9 additions & 1 deletion install/docker/fs/etc/s6-overlay/s6-rc.d/dbus/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/bash

if [[ "${SCRYPTED_DOCKER_AVAHI}" != "true" ]]; then
echo "SCRYPTED_DOCKER_AVAHI != true, not starting dbus-daemon" >/dev/stderr
while true
do
sleep 1000
done
fi

echo "Starting dbus..."
exec dbus-daemon --system --nofork
exec dbus-daemon --system --nofork
12 changes: 11 additions & 1 deletion install/docker/fs/etc/s6-overlay/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash

if [[ "${SCRYPTED_DOCKER_AVAHI}" != "true" ]]; then
echo "SCRYPTED_DOCKER_AVAHI != true, won't manage dbus nor avahi-daemon" >/dev/stderr
exit 0
fi

if grep -qE " ((/var)?/run/dbus|(/var)?/run/avahi-daemon(/socket)?) " /proc/mounts; then
echo "dbus and/or avahi-daemon volumes are bind mounted, won't touch them" >/dev/stderr
exit 0
fi

# make run folders
mkdir -p /var/run/dbus
mkdir -p /var/run/avahi-daemon
Expand All @@ -22,4 +32,4 @@ if [ ! -z "$DSM_HOSTNAME" ]; then
sed -i "s/.*host-name.*/host-name=${DSM_HOSTNAME}/" /etc/avahi/avahi-daemon.conf
else
sed -i "s/.*host-name.*/#host-name=/" /etc/avahi/avahi-daemon.conf
fi
fi

0 comments on commit fac112f

Please sign in to comment.