1.0.005 - Improve connection validation

Based on: https://github.com/RandomNinjaAtk/docker-lidarr-extended/issues/161
pull/24/head
RandomNinjaAtk 2 years ago committed by GitHub
parent da271f5804
commit d91667ac52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash
scriptVersion="1.0.004"
scriptVersion="1.0.005"
notfidedBy="Sonarr"
arrRootFolderPath="$(dirname "$sonarr_series_path")"
arrFolderPath="$sonarr_series_path"
@ -43,17 +43,27 @@ if [ "$arrEventType" == "Test" ]; then
exit 0
fi
# Validate connection
plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
if [ $plexVersion = null ]; then
log "$notfidedBy :: ERROR :: Cannot communicate with Plex"
log "$notfidedBy :: ERROR :: Please check your plexUrl and plexToken"
log "$notfidedBy :: ERROR :: Configured plexUrl \"$plexUrl\""
log "$notfidedBy :: ERROR :: Configured plexToken \"$plexToken\""
log "$notfidedBy :: ERROR :: Exiting..."
plexConnectionError () {
log "ERROR :: Cannot communicate with Plex"
log "ERROR :: Please check your plexUrl and plexToken"
log "ERROR :: Configured plexUrl \"$plexUrl\""
log "ERROR :: Configured plexToken \"$plexToken\""
log "ERROR :: Exiting..."
exit
}
# Validate connection
if curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . &>/dev/null; then
plexVersion=$(curl -s "$plexUrl/?X-Plex-Token=$plexToken" | xq . | jq -r '.MediaContainer."@version"')
if [ "$plexVersion" == "null" ]; then
# Error out if version is null, indicates bad token
plexConnectionError
else
log "Plex Connection Established, version: $plexVersion"
fi
else
log "$notfidedBy :: Plex Connection Established, version: $plexVersion"
# Error out if error in curl | xq . command output
plexConnectionError
fi
plexLibraries="$(curl -s "$plexUrl/library/sections?X-Plex-Token=$plexToken")"

Loading…
Cancel
Save