diff --git a/README.md b/README.md index 5caf39c..50f7ef7 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,22 @@ So now you can run the `docker-compose.yaml` as usual: docker-compose up -d ``` +## Environment Variables + +The container can be entirely configured using the environment variables listed on the following table: + +VARIABLE|DESCRIPTION +:---|:--- +CARD_NAME|Alsa name of the audio card. Example for xmos dac might be `DAC`, defaults to an empty string +CARD_INDEX|Alsa index of the audio card, defaults to `-1` +FRIENDLY_NAME|Friendly name of the device, will be shown on Tidal Apps. Defaults to `TIDAL connect` +MODEL_NAME|Model name of the device. Defaults to `Audio Streamer` +MQA_CODEC|Can't comment a lot on this, defaults to `false` +MQA_PASSTHROUGH|Can't comment a lot on this, defaults to `false` +SLEEP_TIME_SEC|Sleep time before starting the real app, after starting tmux. Defaults to `3` +RESTART_ON_FAIL|Enables auto restart (see issue [#16](https://github.com/GioF71/tidal-connect/issues/16)), defaults to `1` +RESTART_WAIT_SEC|Wait time in seconds before trying restart (see RESTART_ON_FAIL), defaults to 30 + ## Moode Audio It is possible to use this solution for easy installation of Tidal Connect on [Moode Audio](https://moodeaudio.org/). diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh index 69d393c..5dbed0c 100755 --- a/bin/entrypoint.sh +++ b/bin/entrypoint.sh @@ -61,18 +61,29 @@ echo "Starting Speaker Application in Background (TMUX)" echo "Sleeping for a while ($SLEEP_TIME_SEC seconds)..." sleep $SLEEP_TIME_SEC -echo "Starting TIDAL Connect ..." -/app/ifi-tidal-release/bin/tidal_connect_application \ - --tc-certificate-path "/app/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat" \ - --playback-device "default" \ - -f "${FRIENDLY_NAME}" \ - --codec-mpegh true \ - --codec-mqa ${MQA_CODEC} \ - --model-name "${MODEL_NAME}" \ - --disable-app-security false \ - --disable-web-security false \ - --enable-mqa-passthrough ${MQA_PASSTHROUGH} \ - --log-level 3 \ - --enable-websocket-log "0" +while true +do + echo "Starting TIDAL Connect ..." + /app/ifi-tidal-release/bin/tidal_connect_application \ + --tc-certificate-path "/app/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat" \ + --playback-device "default" \ + -f "${FRIENDLY_NAME}" \ + --codec-mpegh true \ + --codec-mqa ${MQA_CODEC} \ + --model-name "${MODEL_NAME}" \ + --disable-app-security false \ + --disable-web-security false \ + --enable-mqa-passthrough ${MQA_PASSTHROUGH} \ + --log-level 3 \ + --enable-websocket-log "0" -echo "TIDAL Connect Container Stopped." + echo "TIDAL Connect Container Stopped." + + if [ $RESTART_ON_FAIL -eq 1 ]; then + echo "Sleeping $RESTART_WAIT_SEC seconds before restarting ..." + sleep $RESTART_WAIT_SEC + else + echo "RESTART_ON_FAIL=$RESTART_ON_FAIL, exiting." + break + fi +done \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 645ea32..68e3071 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,9 +17,11 @@ services: - MQA_CODEC=${MQA_CODEC:-false} - MQA_PASSTHROUGH=${MQA_PASSTHROUGH:-false} - SLEEP_TIME_SEC=${SLEEP_TIME:-3} + - RESTART_ON_FAIL=${RESTART_ON_FAIL:-1} + - RESTART_WAIT_SEC=${RESTART_WAIT_SEC:-30} volumes: - ./bin/entrypoint.sh:/entrypoint.sh - /var/run/dbus:/var/run/dbus dns: - ${DNS_SERVER_LIST:-8.8.8.8 8.8.4.4} - restart: unless-stopped + restart: always