From 75ef6acaa4ae1d6c2f85d0c2eb64b3a8b15fe8bb Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Fri, 2 Sep 2022 16:40:50 -0400 Subject: [PATCH] v1.0.002 - Logging enhancements --- root/scripts/recyclarr.sh | 40 ++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/root/scripts/recyclarr.sh b/root/scripts/recyclarr.sh index 91d980a..68402eb 100644 --- a/root/scripts/recyclarr.sh +++ b/root/scripts/recyclarr.sh @@ -1,28 +1,46 @@ #!/usr/bin/env bash -scriptVersion="1.0.001" - -if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then - arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" - if [ "$arrUrlBase" = "null" ]; then - arrUrlBase="" - else - arrUrlBase="/$(echo "$arrUrlBase" | sed "s/\///g")" - fi - arrApiKey="$(cat /config/config.xml | xq | jq -r .Config.ApiKey)" - arrUrl="http://127.0.0.1:7878${arrUrlBase}" +scriptVersion="1.0.002" + +iif [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then + arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" + if [ "$arrUrlBase" = "null" ]; then + arrlBase="" + else + arrUrlBase="/$(echo "$arrUrlBase" | sed "s/\///g")" + fi + arrApiKey="$(cat /config/config.xml | xq | jq -r .Config.ApiKey)" + arrPort="$(cat /config/config.xml | xq | jq -r .Config.Port)" + arrUrl="http://127.0.0.1:${arrPort}${arrUrlBase}" +fi + +# auto-clean up log file to reduce space usage +if [ -f "/config/logs/Recyclarr.txt" ]; then + find /config/logs -type f -name "Recyclarr.txt" -size +1024k -delete fi +exec &>> "/config/logs/Recyclarr.txt" +chmod 666 "/config/logs/Recyclarr.txt" + +log () { + m_time=`date "+%F %T"` + echo $m_time" :: Recycalarr :: "$1 +} + # Configure Yaml with URL and API Key sed -i "s%arrUrl%$arrUrl%g" "/recyclarr.yaml" sed -i "s%arrApi%$arrApiKey%g" "/recyclarr.yaml" if [ ! -f /config/extended/configs/recyclarr.yaml ]; then + log "Importing default recylarr config file to: /config/extended/configs/recyclarr.yaml" cp "/recyclarr.yaml" "/config/extended/configs/recyclarr.yaml" chmod 766 "/config/extended/configs/recyclarr.yaml" chown abc:abc "/config/extended/configs/recyclarr.yaml" fi + # update radarr +log "Updating Radarr via Recyclarr" /recyclarr/recyclarr radarr -c /config/extended/configs/recyclarr.yaml --app-data /recylarr +log "Complete" exit