plexupdate
plexupdate copied to clipboard
Version parsing for upgrade decision
I slightly changed the IF block. It is comparing full version names with different hashes for same version in the current state of the script. For example:
New Ver: 1.22.2.4282-a97b03fad
Cur Ver: 1.22.2.4282-6000
I cut the suffix from the version, so only the part before the first dash is taken into the account in the IF. In the example above it would parse both new and current versions to 1.22.2.4282
I'm only using the shorter versions to decide if upgrading is necessary, so you can still see the full version in logs.
Another option is to get the right version number, e.g., by
serverIP=$(ip -o route get to 1.2.3.4 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
curversion=$(curl -s "http://$serverIP:32400/?X-Plex-Token=$token" | grep -oP "(?<=<MediaContainer)[^>]+" | grep -oP 'version="\K[^"]+')