diff --git a/Dockerfile b/Dockerfile index a7cdb22..6a4c8dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -177,7 +177,7 @@ USER dubo-dubon-duponey # Disable by default as that prevents the zeroconf server to be started by librespot unfortunately... ENV _SERVICE_NICK="" -ENV _SERVICE_TYPE="spotify-connect" +ENV _SERVICE_TYPE="_spotify-connect._tcp" COPY --from=assembly --chown=$BUILD_UID:root /dist / @@ -186,7 +186,7 @@ COPY --from=assembly --chown=$BUILD_UID:root /dist / # Whether to enable MDNS broadcasting or not ENV MOD_MDNS_ENABLED=false # Type to advertise -ENV MOD_MDNS_TYPE="_$_SERVICE_TYPE._tcp" +ENV ADVANCED_MOD_MDNS_TYPE="$_SERVICE_TYPE" # Name is used as a short description for the service ENV MOD_MDNS_NAME="$_SERVICE_NICK mDNS display name" # The service will be annonced and reachable at $MOD_MDNS_HOST.local (set to empty string to disable mDNS announces entirely) diff --git a/context/runtime/boot/entrypoint.sh b/context/runtime/boot/entrypoint.sh index 4053654..cf59dd1 100644 --- a/context/runtime/boot/entrypoint.sh +++ b/context/runtime/boot/entrypoint.sh @@ -8,11 +8,11 @@ readonly root # shellcheck source=/dev/null . "$root/mdns.sh" -helpers::dir::writable /tmp +helpers::dir::writable "$XDG_CACHE_HOME" readonly PORT="${PORT:-10042}" # This is purely cached music, so, disposable and transient -args=(--cache-size-limit 8G --cache /tmp/cache --name "${MOD_MDNS_NAME:-Sproutify}" --bitrate 320 --device-type speaker --zeroconf-port "$PORT") +args=(--cache-size-limit 8G --cache "$XDG_CACHE_HOME"/spotify --name "${MOD_MDNS_NAME:-Sproutify}" --bitrate 320 --device-type speaker --zeroconf-port "$PORT") # Hook the experimental display script if asked to [ ! "$SPOTIFY_CLIENT_ID" ] || [ ! "$SPOTIFY_CLIENT_SECRET" ] || [ ! "$DISPLAY_ENABLED" ] || args+=(--onevent /boot/onevent.sh) diff --git a/context/runtime/boot/mdns.sh b/context/runtime/boot/mdns.sh index 4afac4a..02242e6 100755 --- a/context/runtime/boot/mdns.sh +++ b/context/runtime/boot/mdns.sh @@ -35,6 +35,32 @@ mdns::records::resolve(){ printf "%s %s" "$server" "$port" } +mdns::start::default(){ + local host="${1:-}" + local name="${2:-}" + local with_http_proxy="${3:-}" + local with_http_proxy_https="${4:-}" + local with_tls_proxy="${5:-}" + local with_station="${6:-}" + local type="${7:-}" + + local http_proxy_https_port="${7:-443}" + local http_proxy_http_port="${8:-80}" + local tls_proxy_port="${9:-443}" + + local port="$tls_proxy_port" + + [ "$with_http_proxy" != true ] || { + port="$([ "$with_http_proxy_https" == true ] && printf "%s" "$http_proxy_https_port" || printf "%s" "$http_proxy_http_port")" + type="${type:-_http._tcp}" + } + [ "$with_tls_proxy" != true ] || type="${type:-_tls._tcp}" + + mdns::records::add "$type" "$host" "$name" "$port" + [ "$with_station" != true ] || mdns::records::add "_workstation._tcp" "$host" "$name" "$port" + mdns::start::broadcaster +} + mdns::start::broadcaster(){ [ ! -e "$_default_mod_mdns_configuration_path" ] || mdns::records::load "$_default_mod_mdns_configuration_path" local IFS="," @@ -83,10 +109,10 @@ mdns::start::dbus(){ # https://man7.org/linux/man-pages/man3/sd_bus_default.3.html # https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html - # $XDG_STATE_HOME=/tmp/state + # $XDG_RUNTIME_DIR=/tmp/runtime # Configuration file also has that ^ hardcoded, so, cannot use the variable... - local dbussocket=/tmp/state/dbus/system_bus_socket + local dbussocket=/tmp/runtime/dbus/system_bus_socket # Ensure directory exists helpers::dir::writable "$(dirname "$dbussocket")" create