Spotify integration added

This commit is contained in:
2026-05-17 13:35:34 +02:00
parent 9a9275dae5
commit 4d53efc9e4
16 changed files with 1890 additions and 82 deletions
+18 -3
View File
@@ -1,8 +1,11 @@
#!/usr/bin/env bash
# Mopidy entrypoint
# Ensures the audio FIFO exists (Snapserver must open it too, ordering matters)
# Mopidy entrypoint — runs as root, fixes permissions, then drops to mopidy user.
set -e
# Fix ownership of the data volume (may be stale from a previous container build
# with a different mopidy uid, or from Docker initialising a new volume as root).
chown -R mopidy:audio /var/lib/mopidy 2>/dev/null || true
FIFO=/audio/mopidy.fifo
# Create FIFO if missing (init-pipes.sh should have done this, but be safe)
@@ -14,9 +17,21 @@ fi
echo "[mopidy] FIFO ready: $FIFO"
# Load Spotify credentials from shared config volume (written by the settings UI).
# Values here take precedence over env vars from docker-compose / .env.
_SPOTIFY_JSON=/config/shared/spotify.json
if [[ -f "$_SPOTIFY_JSON" ]]; then
_ID=$(python3 -c "import json; d=json.load(open('$_SPOTIFY_JSON')); print(d.get('client_id',''))" 2>/dev/null || true)
_SEC=$(python3 -c "import json; d=json.load(open('$_SPOTIFY_JSON')); print(d.get('client_secret',''))" 2>/dev/null || true)
[[ -n "$_ID" ]] && export SPOTIFY_CLIENT_ID="$_ID"
[[ -n "$_SEC" ]] && export SPOTIFY_CLIENT_SECRET="$_SEC"
echo "[mopidy] Spotify credentials loaded from shared config"
fi
# Expand only our own vars — leave Mopidy's $XDG_* vars untouched
envsubst '${SPOTIFY_CLIENT_ID}${SPOTIFY_CLIENT_SECRET}${SNAPSERVER_HOST}${BEETS_HOST}' \
< /config/mopidy.conf > /tmp/mopidy.conf
echo "[mopidy] Config expanded from template"
exec "$@"
# Drop from root → mopidy user for the actual Mopidy process
exec gosu mopidy "$@"