parent
08de9a7faf
commit
f99f2aed74
1 changed files with 31 additions and 20 deletions
|
@ -1,20 +1,39 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
scriptVersion="1.3"
|
scriptVersion="1.4"
|
||||||
scriptName="AutoExtras"
|
scriptName="AutoExtras"
|
||||||
|
|
||||||
#### 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 [ "$enableExtras" != "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 [ "$enableExtras" != "true" ]; then
|
||||||
log "Script is not enabled, enable by setting enableExtras to \"true\" by modifying the \"/config/extended.conf\" config file..."
|
log "Script is not enabled, enable by setting enableExtras to \"true\" by modifying the \"/config/extended.conf\" config file..."
|
||||||
log "Sleeping (infinity)"
|
log "Sleeping (infinity)"
|
||||||
sleep infinity
|
sleep infinity
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$autoExtrasScriptInterval" ]; then
|
||||||
|
autoExtrasScriptInterval="24h"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
getArrAppInfo () {
|
getArrAppInfo () {
|
||||||
# Get Arr App information
|
# Get Arr App information
|
||||||
|
@ -53,16 +72,6 @@ verifyApiAccess () {
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoExtrasProcess () {
|
AutoExtrasProcess () {
|
||||||
# auto-clean up log file to reduce space usage
|
|
||||||
if [ -f "/config/logs/AutoExtras.txt" ]; then
|
|
||||||
find /config/logs -type f -name "AutoExtras.txt" -size +1024k -delete
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "/config/logs/AutoExtras.txt" ]; then
|
|
||||||
touch "/config/logs/AutoExtras.txt"
|
|
||||||
chmod 666 "/config/logs/AutoExtras.txt"
|
|
||||||
fi
|
|
||||||
exec &> >(tee -a "/config/logs/AutoExtras.txt")
|
|
||||||
|
|
||||||
sonarrSeriesList=$(curl -s --header "X-Api-Key:"${arrApiKey} --request GET "$arrUrl/api/v3/series")
|
sonarrSeriesList=$(curl -s --header "X-Api-Key:"${arrApiKey} --request GET "$arrUrl/api/v3/series")
|
||||||
sonarrSeriesTotal=$(echo "${sonarrSeriesList}" | jq -r '.[].id' | wc -l)
|
sonarrSeriesTotal=$(echo "${sonarrSeriesList}" | jq -r '.[].id' | wc -l)
|
||||||
|
@ -84,14 +93,16 @@ AutoExtrasProcess () {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Starting Script...."
|
|
||||||
for (( ; ; )); do
|
for (( ; ; )); do
|
||||||
let i++
|
let i++
|
||||||
|
logfileSetup
|
||||||
|
log "Script starting..."
|
||||||
|
verifyConfig
|
||||||
getArrAppInfo
|
getArrAppInfo
|
||||||
verifyApiAccess
|
verifyApiAccess
|
||||||
AutoExtrasProcess
|
AutoExtrasProcess
|
||||||
echo "Script sleeping for 24 hours..."
|
echo "Script sleeping for $autoExtrasScriptInterval..."
|
||||||
sleep 24h
|
sleep $autoExtrasScriptInterval
|
||||||
done
|
done
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in a new issue