From 5b0fe1505cba4133a7e28cc0d818c61ef289d5f9 Mon Sep 17 00:00:00 2001 From: Giovanni Fulco Date: Mon, 25 Mar 2024 10:02:44 +0100 Subject: [PATCH] 383 feature support upnp log level and filename (#384) * Add support for upnp log file and level #383 * Corrected var names to avoid overlaps * Final cleanup - replace whole words - proper variable names --- Dockerfile | 5 ++++- README.md | 6 ++++-- app/bin/config-builder.sh | 2 +- app/bin/run-upmpdcli.sh | 22 +++++++++++++++++----- app/conf/upmpdcli.conf | 5 ++++- doc/change-history.md | 1 + 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b332bc..4da0fbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN if [ "$BUILD_MODE" = "full" ]; then \ apt-get install -y python3 python3-pip; \ fi -COPY app/install/* /app/install +COPY app/install/* /app/install/ RUN chmod u+x /app/install/*.sh RUN /app/install/setup.sh @@ -190,6 +190,9 @@ ENV MEDIA_SERVER_FRIENDLY_NAME "" ENV LOG_ENABLE "" ENV LOG_LEVEL "" +ENV UPNP_LOG_ENABLE "" +ENV UPNP_LOG_LEVEL "" + ENV DUMP_ADDITIONAL_RADIO_LIST "" ENV WEBSERVER_DOCUMENT_ROOT "" diff --git a/README.md b/README.md index fbf9516..c311e50 100644 --- a/README.md +++ b/README.md @@ -260,8 +260,10 @@ HRA_ENABLE|Set to `yes` to enable HRA support, defaults to `no` HRA_USERNAME|Your HRA account username HRA_PASSWORD|Your HRA account password HRA_LANG|Your HRA account language -LOG_ENABLE|Set to `yes` to enable. If enabled, the logfile is `/log/upmpdcli.log`. Otherwise, umpdcli will log to stderr. -LOG_LEVEL|Defaults to `2` +LOG_ENABLE|Set to `yes` to enable to enable logging to file. If enabled, the logfile is `/log/upmpdcli.log`. Otherwise, upmpdcli will log to stderr. +LOG_LEVEL|Sets the log level, if not set the upmpdcli default will apply +UPNP_LOG_ENABLE|Set to `yes` to enable logging to file. If enabled, the logfile is `/log/upnp.log`. Otherwise, upmpdcli will log to stderr. +UPNP_LOG_LEVEL|Sets the log level for upnp, if not set the upmpdcli default will apply DUMP_ADDITIONAL_RADIO_LIST|Dumps the additional radio file when set to `yes` WEBSERVER_DOCUMENT_ROOT|Directory from which the internal HTTP server will directly serve files (e.g. icons), disabled by default STARTUP_DELAY_SEC|Delay before starting the application, defaults to `0`. This can be useful if your container is set up to start automatically, so that you can resolve race conditions with mpd and with squeezelite if all those services run on the same audio device. I experienced issues with my Asus Tinkerboard, while the Raspberry Pi has never really needed this. Your mileage may vary. Feel free to report your personal experience. diff --git a/app/bin/config-builder.sh b/app/bin/config-builder.sh index 9d32929..1ab07c3 100644 --- a/app/bin/config-builder.sh +++ b/app/bin/config-builder.sh @@ -13,6 +13,6 @@ set_parameter() { echo "enabling key [$PARAM_KEY]" sed -i "s/#${PARAM_KEY}/${PARAM_KEY}/g" $CFG_FILE; echo "Setting value for key [${PARAM_KEY}] to [${PARAM_VALUE}]" - sed -i "s/${PARAM_NAME}/${PARAM_VALUE}/g" $CFG_FILE; + sed -i "s/\b${PARAM_NAME}\b/${PARAM_VALUE}/g" $CFG_FILE; fi } diff --git a/app/bin/run-upmpdcli.sh b/app/bin/run-upmpdcli.sh index 41bd0b0..f21c85c 100644 --- a/app/bin/run-upmpdcli.sh +++ b/app/bin/run-upmpdcli.sh @@ -167,12 +167,24 @@ fi cp $SOURCE_CONFIG_FILE $CONFIG_FILE -# log support +# log file support if [ "${LOG_ENABLE^^}" == "YES" ]; then - sed -i "s/#logfilename/logfilename/g" $CONFIG_FILE; - if [ -n "${LOG_LEVEL}" ]; then - set_parameter $CONFIG_FILE LOG_LEVEL "$LOG_LEVEL" loglevel - fi + sed -i "s/#logfilename/logfilename/g" $CONFIG_FILE +fi + +# log level +if [ -n "${LOG_LEVEL}" ]; then + set_parameter $CONFIG_FILE LOG_LEVEL "$LOG_LEVEL" loglevel +fi + +# upnp log file support +if [ "${UPNP_LOG_ENABLE^^}" == "YES" ]; then + sed -i "s/#upnplogfilename/upnplogfilename/g" $CONFIG_FILE; +fi + +# upnp log level +if [ -n "${UPNP_LOG_LEVEL}" ]; then + set_parameter $CONFIG_FILE UPNP_LOG_LEVEL "$UPNP_LOG_LEVEL" upnploglevel fi set_upnp_iface=0 diff --git a/app/conf/upmpdcli.conf b/app/conf/upmpdcli.conf index 8d6cd32..dcf5613 100644 --- a/app/conf/upmpdcli.conf +++ b/app/conf/upmpdcli.conf @@ -1,9 +1,12 @@ cachedir = CACHE_DIRECTORY radiolist = /tmp/radiolist.conf upradiostitle = Upmpdcli Radio List -logfilename = LOG_DIRECTORY/upmpdcli.log +#logfilename = LOG_DIRECTORY/upmpdcli.log #log level defaults to 2 #loglevel = LOG_LEVEL +#upnplogfilename = LOG_DIRECTORY/upnp.log +#upnp log level defaults to 1 +#upnploglevel = UPNP_LOG_LEVEL #pkgdatadir=/usr/share/upmpdcli #pidfile = /var/run/upmpdcli.pid #upnpiface = UPNPIFACE diff --git a/doc/change-history.md b/doc/change-history.md index c815b5d..fb137e9 100644 --- a/doc/change-history.md +++ b/doc/change-history.md @@ -2,6 +2,7 @@ Change Date|Major Changes ---|--- +2024-03-24|Add support for upnp log file and level (see issue [#383](https://github.com/GioF71/upmpdcli-docker/issues/383))) 2024-03-05|Review default naming (see issue [#381](https://github.com/GioF71/upmpdcli-docker/issues/381))) 2024-03-05|Automatically set upnpip instead of upnpiface (see issue [#379](https://github.com/GioF71/upmpdcli-docker/issues/379))) 2024-02-29|Update workflow actions (see issue [#377](https://github.com/GioF71/upmpdcli-docker/issues/377)))