I found this script, while checking to see how to get my Plex to Auto-Update. Made some small changes, so that it checks the version to make sure it is higher & not just different. Also did some formatting & removed the sleep function as it is a hack, imo.
Thanks for the advice! The part that gets the Plex Token still wasnât working for me, so I just found it manually and pasted it in (I guess it doesnât change?) The script seems to run through happily now without errors, finding the correct current and new versions numbers - so I just need to wait for Plex to release an update to see if the downloading / updating part works ⊠!
To clarify, the following link describes the process for determining your own plex-pass-token, however, I was just wondering if you declared $token as an absolute earlier in your script, and didnât include that declaraion (for obvious reasons), or if you had a programatic mechanism for dynamically retrieving your token, in the script (which now that I say itâŠseems unlikely).
$token was set by using this line from the original post. I havenât had to change it as it has been working for me without issue. I see others are having issues not sure why though.
Hey @euphnutz - just wanted to say, there was a Plex server update today for the first time since I added this script, ant it worked perfectly. So thanks for your help!
EDIT: Looks like yours isnât doing plex-pass versions, the original is, makes sense. Carry on, ha. I do like how yours is written to help weed out any bugs, very clean. Much appreciated!
I added the token line and updated the URL, now its appearing and working as expected:
Hey there, once included all of the modifications above @mpalensh , today there is an update, however I can see the following error.
New version: 1.18.2.2029-36236cc4c
Current version: 1.18.2.2015-5a99a9a46
New version available!
parse error: Invalid numeric literal at line 1, column 4
http://: Invalid host name.
Failed to install package /tmp/plex/*.spk, error = [150]
I can see the script has an https:// to be honest, not sure why you would see that http:// to be honestâŠ
To be clear, my full, modifications included, script, follows.
#!/bin/bash
mkdir -p /tmp/plex/
TOKEN=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+')
URL=$(echo "https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=${TOKEN}")
JSON=$(curl -s ${URL})
NEW_VERSION=$(echo $JSON | jq -r .nas.Synology.version)
echo "New version: ${NEW_VERSION}"
CURRENT_VERSION=$(synopkg version "Plex Media Server")
echo "Current version: ${CURRENT_VERSION}"
if [[ "${NEW_VERSION}" > "${CURRENT_VERSION}" ]]; then
echo "New version available!"
/usr/syno/bin/synonotify PKGHasUpgrade '{"[%HOSTNAME%]": $(hostname), "[%OSNAME%]": "Synology", "[%PKG_HAS_UPDATE%]": "Plex", "[%COMPANY_NAME%]": "Synology"}'
cpu=$(uname -m)
URL=$(echo â${JSON}â | jq -r '.nas.Synology.releases[] | select(.build=="linux-'"${CPU}"'") | .url')
/bin/wget "$url" -P /tmp/plex/
/usr/syno/bin/synopkg install /tmp/plex/*.spk && /usr/syno/bin/synopkg start "Plex Media Server" && rm -rf /tmp/plex/
else
echo "Plex is up to date."
fi
exit 0
New version: 1.18.2.2029-36236cc4c
Current version: 1.18.2.2015-5a99a9a46
New version available!
+1
CPU is: x86_64
+2
parse error: Invalid numeric literal at line 1, column 4
URL is:
+3
http://: Invalid host name.
+4
Failed to install package /tmp/plex/*.spk, error = [150]
The tip re. the case has still helped me resolve by swapping to the standard double quotes around ${JSON}: