v1.0.0 - Validate connection, error out if cannot connect

pull/16/head
RandomNinjaAtk 3 years ago committed by GitHub
parent 6467ebaff9
commit b7ec8379b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
lidarrRootFolderPath="$(dirname "$lidarr_artist_path")" lidarrRootFolderPath="$(dirname "$lidarr_artist_path")"
version=1.0.0
# auto-clean up log file to reduce space usage # auto-clean up log file to reduce space usage
if [ -f "/config/logs/PlexNotify.txt" ]; then if [ -f "/config/logs/PlexNotify.txt" ]; then
find /config/logs -type f -name "PlexNotify.txt" -size +1024k -delete find /config/logs -type f -name "PlexNotify.txt" -size +1024k -delete
fi fi
exec &>> "/config/logs/PlexNotify.txt" exec &>> "/config/logs/PlexNotify.txt"
chmod 777 "/config/logs/PlexNotify.txt" chmod 777 "/config/logs/PlexNotify.txt"
@ -18,15 +20,18 @@ if [ "$lidarr_eventtype" == "Test" ]; then
exit 0 exit 0
fi fi
until false # Validate connection
do plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
taskCount=$(ps aux | grep Plex_MusicVideos.bash | grep -v grep | wc -l) if [ $plexVersion = null ]; then
if [ "$taskCount" -ge "1" ]; then log "ERROR :: Cannot communicate with Plex"
sleep 1 log "ERROR :: Please check your plexUrl and plexToken"
else log "ERROR :: Configured plexUrl \"$plexUrl\""
break log "ERROR :: Configured plexToken \"$plexToken\""
fi log "ERROR :: Exiting..."
done exit
else
log "Plex Connection Established, version: $plexVersion"
fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)" plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken" | xq .)"
if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | .\"@key\"" &>/dev/null; then if echo "$plexLibraries" | jq -r ".MediaContainer.Directory[] | .\"@key\"" &>/dev/null; then

Loading…
Cancel
Save