@@ -1,20 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
scriptVersion="1.3"
|
||||
scriptVersion="1.4"
|
||||
scriptName="InvalidSeriesAutoCleaner"
|
||||
|
||||
#### Import Settings
|
||||
source /config/extended.conf
|
||||
|
||||
log () {
|
||||
m_time=`date "+%F %T"`
|
||||
echo $m_time" :: $scriptName :: $scriptVersion :: "$1
|
||||
}
|
||||
|
||||
if [ "$enableInvalidSeriesAutoCleaner" != "true" ]; then
|
||||
logfileSetup () {
|
||||
# auto-clean up log file to reduce space usage
|
||||
if [ -f "/config/logs/$scriptName.txt" ]; then
|
||||
find /config/logs -type f -name "$scriptName.txt" -size +1024k -delete
|
||||
fi
|
||||
|
||||
if [ ! -f "/config/logs/$scriptName.txt" ]; then
|
||||
touch "/config/logs/$scriptName.txt"
|
||||
chmod 666 "/config/logs/$scriptName.txt"
|
||||
fi
|
||||
exec &> >(tee -a "/config/logs/$scriptName.txt")
|
||||
}
|
||||
|
||||
verifyConfig () {
|
||||
#### Import Settings
|
||||
source /config/extended.conf
|
||||
|
||||
if [ "$enableInvalidSeriesAutoCleaner" != "true" ]; then
|
||||
log "Script is not enabled, enable by setting enableInvalidSeriesAutoCleaner to \"true\" by modifying the \"/config/extended.conf\" config file..."
|
||||
log "Sleeping (infinity)"
|
||||
sleep infinity
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$invalidSeriesAutoCleanerScriptInterval" ]; then
|
||||
invalidSeriesAutoCleanerScriptInterval="1h"
|
||||
fi
|
||||
}
|
||||
|
||||
getArrAppInfo () {
|
||||
# Get Arr App information
|
||||
@@ -92,14 +111,16 @@ InvalidSeriesAutoCleanerProcess () {
|
||||
done
|
||||
}
|
||||
|
||||
echo "Starting Script...."
|
||||
for (( ; ; )); do
|
||||
let i++
|
||||
getArrAppInfo
|
||||
verifyApiAccess
|
||||
logfileSetup
|
||||
log "Script starting..."
|
||||
verifyConfig
|
||||
getArrAppInfo
|
||||
verifyApiAccess
|
||||
InvalidSeriesAutoCleanerProcess
|
||||
echo "Script sleeping for 2 hours..."
|
||||
sleep 2h
|
||||
echo "Script sleeping for $invalidSeriesAutoCleanerScriptInterval..."
|
||||
sleep $invalidSeriesAutoCleanerScriptInterval
|
||||
done
|
||||
|
||||
exit
|
||||
|
||||
Reference in New Issue
Block a user