Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dubo-dubon-duponey committed Mar 18, 2024
1 parent c3cb003 commit 1cb3465
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 /

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions context/runtime/boot/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 28 additions & 2 deletions context/runtime/boot/mdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=","
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1cb3465

Please sign in to comment.