Skip to content

Commit

Permalink
[Feature] Allow user to specify dns address #13 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 authored Jul 18, 2023
1 parent f2c5767 commit 1d3d5b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PARAM|DESCRIPTION
-c|MQA Codec, defaults to `false`
-p|MQA Passthrough, defaults to `false`
-t|Sleep time in seconds be, defaults to `3`
-d|DNS Server list, defaults to `8.8.8.8 8.8.4.4` (Google's DNS servers)

I recommend to use the `-n` parameter instead of `-i`, because the index of the devices might change across restarts.
If you already used the `configure.sh` command and you are experiencing issues (because of the card has changed its index), you can run the command again. In the latest version, the card index is calculated during the container startup phase and hopefully there will not be any need to use `configure.sh` again unless you change the audio device you want to use.
Expand Down Expand Up @@ -120,6 +121,7 @@ An already started tidal-connect container should start working immediately, at

Date|Comment
:---|:---
2023-07-18|Allow user-specified dns server(s), see issue [#13](https://github.com/GioF71/tidal-connect/issues/13)
2023-07-07|Fixed asound.conf generation from card index, see issue ([#2](https://github.com/GioF71/tidal-connect/issues/2))
2023-06-02|First unfolding seems to be working
2023-06-02|Some effort to avoid resampling
Expand Down
34 changes: 32 additions & 2 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# error codes
# 1 cannot specify both index and name

set -ex
set -e

ENV_FILE=.env
chmod 755 bin/entrypoint.sh

while getopts n:i:f:m:c:p:t: flag
while getopts n:i:f:m:c:p:t:d: flag
do
case "${flag}" in
n) card_name=${OPTARG};;
Expand All @@ -18,6 +18,8 @@ do
c) mqa_codec=${OPTARG};;
p) mqa_passthrough=${OPTARG};;
t) sleep_time_sec=${OPTARG};;
d) dns_server_list=${OPTARG};;

esac
done

Expand All @@ -38,28 +40,56 @@ if test -f $ENV_FILE; then
fi

if [[ -n ${friendly_name} ]]; then
echo "Setting FRIENDLY_NAME to [$friendly_name]"
echo "FRIENDLY_NAME=${friendly_name}" >> $ENV_FILE
else
echo "FRIENDLY_NAME not specified"
fi

if [[ -n ${model_name} ]]; then
echo "Setting MODEL_NAME to [$model_name]"
echo "MODEL_NAME=${model_name}" >> $ENV_FILE
else
echo "MODEL_NAME not specified"
fi

if [[ -n ${mqa_codec} ]]; then
echo "Setting MQA_CODEC to [$mqa_codec]"
echo "MQA_CODEC=${mqa_codec}" >> $ENV_FILE
else
echo "MQA_CODEC not specified"
fi

if [[ -n ${mqa_passthrough} ]]; then
echo "Setting MQA_PASSTHROUGH to [$mqa_passthrough]"
echo "MQA_PASSTHROUGH=${mqa_passthrough}" >> $ENV_FILE
else
echo "MQA_PASSTHROUGH not specified"
fi

if [[ -n ${sleep_time_sec} ]]; then
echo "Setting SLEEP_TIME_SEC to [$sleep_time_sec]"
echo "SLEEP_TIME_SEC=${sleep_time_sec}" >> $ENV_FILE
else
echo "SLEEP_TIME_SEC not specified"
fi

if [[ -n ${dns_server_list} ]]; then
echo "Setting DNS_SERVER_LIST to [$sleep_time_sec]"
echo "DNS_SERVER_LIST=${dns_server_list}" >> $ENV_FILE
else
echo "DNS_SERVER_LIST not specified"
fi

if [[ -n "${card_name}" ]]; then
echo "Setting CARD_NAME to [$card_name]"
echo "CARD_NAME=${card_name}" >> $ENV_FILE
elif [[ -n "${card_index}" ]]; then
echo "Setting CARD_INDEX to [$card_index]"
echo "CARD_INDEX=${card_index}" >> $ENV_FILE
echo "CARD_NAME=NOT_SET" >> $ENV_FILE
fi

echo -e "\nFinal .env file:\n"
cat .env

3 changes: 1 addition & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ services:
- ./bin/entrypoint.sh:/entrypoint.sh
- /var/run/dbus:/var/run/dbus
dns:
- 8.8.8.8
- 8.8.4.4
- ${DNS_SERVER_LIST:-8.8.8.8 8.8.4.4}
restart: unless-stopped

0 comments on commit 1d3d5b6

Please sign in to comment.