v1.0.1 - Start when API test is successful

This commit is contained in:
RandomNinjaAtk 2023-03-18 11:58:38 -04:00 committed by GitHub
parent e67398a7b4
commit 3306d3645f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion="1.0.0"
scriptVersion="1.0.1"
######## Settings
scriptInterval="15m"
@ -38,6 +38,8 @@ QueueCleanerProcess () {
chmod 666 "/config/logs/QueueCleaner.txt"
exec &> >(tee -a "/config/logs/QueueCleaner.txt")
verifyApiAccess
if [ "$arrName" == "Sonarr" ]; then
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownSeriesItems=true&apikey=${arrApiKey}" | jq -r .records[])"
fi
@ -80,6 +82,26 @@ QueueCleanerProcess () {
fi
}
verifyApiAccess () {
until false
do
arrApiTest=""
if [ "$arrName" == "Sonarr" ] || [ "$arrName" == "Radarr" ]; then
arrApiTest=$(curl -s "$arrUrl/api/v3/system/status?apikey=$arrApiKey" | jq -r .instanceName)
elif [ "$arrName" == "Lidarr" ]; then
arrApiTest=$(curl -s "$arrUrl/api/v1/system/status?apikey=$arrApiKey" | jq -r .instanceName)
fi
if [ "$arrApiTest" == "$arrName" ]; then
arrVersion=$(curl -s "$arrUrl/api/v3/system/status?apikey=$arrApiKey" | jq -r .version)
log "$arrName Version: $arrVersion"
break
else
log "$arrName is not ready, sleeping until valid response..."
sleep 1
fi
done
}
if [ "$enableQueueCleaner" == "false" ]; then
log "ERROR :: Script disabled, exiting..."
exit
@ -87,9 +109,6 @@ fi
arrName="$(cat /config/config.xml | xq | jq -r .Config.InstanceName)"
if [ "$arrName" == "Sonarr" ] || [ "$arrName" == "Radarr" ] || [ "$arrName" == "Lidarr" ]; then
log "Waiting for $arrName to startup, sleeping for 2 minutes..."
sleep 2m
log "Starting Script...."
for (( ; ; )); do
let i++
QueueCleanerProcess