From f8663c48cbcc1b4877d91a7534fdcb38b2e5fa72 Mon Sep 17 00:00:00 2001 From: Giovanni Fulco Date: Mon, 18 Dec 2023 16:38:06 +0100 Subject: [PATCH] [Enhancement] Add config file prefix variable #249 (#251) --- README.md | 3 ++- app/bin/cmd-line-builder.sh | 12 +++++++++--- doc/release.md | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5b35aa6..6100c63 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ SQUEEZELITE_LOG_CATEGORY_STREAM|-d|Support for log level on category `stream` SQUEEZELITE_LOG_CATEGORY_DECODE|-d|Support for log level on category `decode` SQUEEZELITE_LOG_CATEGORY_OUTPUT|-d|Support for log level on category `output` SQUEEZELITE_LOG_CATEGORY_IR|-d|Support for log level on category `ir` +CONFIG_FILE_PREFIX||Prefix for files in volume `/config` STARTUP_DELAY_SEC||Delay before starting the application, defaults to `0` It is possible to add and additional preset configuration file using the volume `/app/assets/additional-presets.conf`. @@ -127,7 +128,7 @@ Possible values for variables `SQUEEZELITE_LOG_CATEGORY_*` are `info`, `debug` o ### Automatic MAC address creation -If you don't provide a value to `SQUEEZELITE_MAC_ADDRESS`, a random mac address will be generated and stored (if possible) under `/config/mac-address.txt`, so it will be reloaded on next restart. +If you don't provide a value to `SQUEEZELITE_MAC_ADDRESS`, a random mac address will be generated and stored (if possible) under `/config/mac-address.txt`, so it will be reloaded on next restart. The file name can be prepended by the optional `CONFIG_FILE_PREFIX`. Use a persistent volume in order to preserve the functionality in the event of container recreation (such as when you update to a newer image). ## Volumes diff --git a/app/bin/cmd-line-builder.sh b/app/bin/cmd-line-builder.sh index 7ce9fd3..e73e644 100644 --- a/app/bin/cmd-line-builder.sh +++ b/app/bin/cmd-line-builder.sh @@ -154,10 +154,16 @@ function cmdline-rates() { function handle_mac_address() { if [[ -z "${SQUEEZELITE_MAC_ADDRESS}" ]]; then + FILE_NAME=mac-address.txt + if [[ -n "${CONFIG_FILE_PREFIX}" ]]; then + FILE_NAME=${CONFIG_FILE_PREFIX}-${FILE_NAME} + fi + FILE_PATH="/config/${FILE_NAME}" + echo "File name for mac-address is [$FILE_PATH]" echo "No mac address, specified, try loading ..." - if [ -f "/config/mac-address.txt" ]; then + if [ -f $FILE_PATH ]; then echo "Found file with mac address ..." - mac=`cat /config/mac-address.txt` + mac=`cat $FILE_PATH` echo "Mac address is ${mac}" SQUEEZELITE_MAC_ADDRESS="${mac}" else @@ -174,7 +180,7 @@ function handle_mac_address() { SQUEEZELITE_MAC_ADDRESS="${mac}" # write if possible if [ -w /config ]; then - echo "${mac}" > /config/mac-address.txt + echo "${mac}" > $FILE_PATH echo "Written generated [${mac}] mac address." else echo "Config directory is not writable" diff --git a/doc/release.md b/doc/release.md index 2da5062..b05618c 100644 --- a/doc/release.md +++ b/doc/release.md @@ -10,6 +10,7 @@ Older build might be dropped in order to save space on docker-hub and incur in l Date|Type|Description :---|:---|:--- +2023-12-18|Improvement|Support for a config file prefix (see [#249](https://github.com/GioF71/squeezelite-docker/issues/249)) 2023-12-18|Improvement|Autogen mac address (see [#247](https://github.com/GioF71/squeezelite-docker/issues/247)) 2023-12-18|Improvement|Arguments in quotes (see [#245](https://github.com/GioF71/squeezelite-docker/issues/245)) 2023-12-17|Improvement|Support output device `-o` also with PulseAudio (see [#243](https://github.com/GioF71/squeezelite-docker/issues/243))