v1.4 - improve logging

This commit is contained in:
RandomNinjaAtk 2023-07-14 19:37:49 +00:00 committed by GitHub
parent 7a081f6ddf
commit 8ffbc5732b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,20 +1,37 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.3" scriptVersion="1.4"
scriptName="Recyclarr" scriptName="Recyclarr"
#### Import Settings
source /config/extended.conf
log () { log () {
m_time=`date "+%F %T"` m_time=`date "+%F %T"`
echo $m_time" :: $scriptName :: $scriptVersion :: "$1 echo $m_time" :: $scriptName :: $scriptVersion :: "$1
} }
if [ "$enableRecyclarr" != "true" ]; then logfileSetup () {
# 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
if [ ! -f "/config/logs/Recyclarr.txt" ]; then
touch "/config/logs/Recyclarr.txt"
chmod 666 "/config/logs/Recyclarr.txt"
fi
exec &> >(tee -a "/config/logs/Recyclarr.txt")
}
verifyConfig () {
#### Import Settings
source /config/extended.conf
if [ "$enableRecyclarr" != "true" ]; then
log "Script is not enabled, enable by setting enableRecyclarr to \"true\" by modifying the \"/config/extended.conf\" config file..." log "Script is not enabled, enable by setting enableRecyclarr to \"true\" by modifying the \"/config/extended.conf\" config file..."
log "Sleeping (infinity)" log "Sleeping (infinity)"
sleep infinity sleep infinity
fi fi
}
getArrAppInfo () { getArrAppInfo () {
# Get Arr App information # Get Arr App information
@ -58,17 +75,6 @@ verifyApiAccess () {
done done
} }
RecyclarrProcess () { RecyclarrProcess () {
# 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
if [ ! -f "/config/logs/Recyclarr.txt" ]; then
touch "/config/logs/Recyclarr.txt"
chmod 666 "/config/logs/Recyclarr.txt"
fi
exec &> >(tee -a "/config/logs/Recyclarr.txt")
# Configure Yaml with URL and API Key # Configure Yaml with URL and API Key
sed -i "s%arrUrl%$arrUrl%g" "/config/extended/recyclarr.yaml" sed -i "s%arrUrl%$arrUrl%g" "/config/extended/recyclarr.yaml"
sed -i "s%arrApi%$arrApiKey%g" "/config/extended/recyclarr.yaml" sed -i "s%arrApi%$arrApiKey%g" "/config/extended/recyclarr.yaml"
@ -83,9 +89,11 @@ RecyclarrProcess () {
log "Complete" log "Complete"
} }
log "Starting Script...." # Loop Script
for (( ; ; )); do for (( ; ; )); do
let i++ let i++
logfileSetup
verifyConfig
getArrAppInfo getArrAppInfo
verifyApiAccess verifyApiAccess
RecyclarrProcess RecyclarrProcess