Script to Auto Update Plex on Synology nas [rev6]

Hey guys I fixed the 289 error when installing.

Package Center -> Settings -> Trust Level -> Any publisher

2 Likes

Hey @aaronc7, I don’t think what you did is the best idea. With this you opened your Synology to potentially any malicious package.
Follow the instructions here, to add Plex certificate to Synology package center and see if this solves your problem.

4 Likes

Thanks for the tip, that worked as well. I probably should have done this a long time ago anyways… I’ve been installing updates manually for a long time and alway just been clicking “yes I want to install from an unknown publisher”. Thanks again!

2 Likes

This is great! Using the builtin notification was what i was thinking after i mentioned email. I wonder if it can tell you the old version and the new version in the notification? I may have to poke around a bit.

Nice idea for a script to automate, thanks for sharing.
Can I suggest that you consider rev 5 to download, verify, and import Plex’s package signing key to reduce the number of people getting errors because they have missed that step.

MC

@SpuddyUK How did you pass the versions into the email. Trying to pass those into the notification but it’s not taking it. Even the %PKG_HAS_UPDATE% variable is coming across just as the variable.

@will.allen_gmail.com why not just enable the Plex repo?

https://support.plex.tv/articles/235974187-enable-repository-updating-for-supported-linux-server-distributions/

1 Like

I cleaned the script up a little, changed some variable names, and used /tmp for the folder where it stores the downloads (rather than /volume1).

2 Likes

Hey guys,

The script looks great!

Just wondered if anyone had any ideas why the JSON bit might not be working on my Synology DS918+?

It seems like there’s some sort of problem getting the https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=[my Plex token] curl bit to finish properly.

The script runs, gets the token, requests the page, but always ends with NEW_VERSION blank, and the message “syntax error: unexpected end of file” for me.

If I try going through the same process step by step (running the curl command so it outputs into a text file) - the text file doesn’t seem to “close” so can’t be processed. But if I try copying that text file and running JQ over it, it finds the “new” version number correctly.

I’m not great at scripting, so have no idea where to look next!

Thanks,

Phil.

Thank you. I did not realize this was available.

2 Likes

Your script does not work for aarch64. I have a DS418 and it downloads the x86 version every time.

@monkeyhat and @trent.curtis

Replace this line:

TOKEN=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+')

With the following:

PMS_PATH=$(find / -path '*/Plex Media Server' -print -quit 2>/dev/null)
TOKEN=$(grep -Po 'PlexOnlineToken="\K[^"]+' "${PMS_PATH}"/Preferences.xml)

And replace the following if block:

  if [ "$CPU" = "x86_64" ] ; then
    URL=$(echo $JSON | jq -r ".nas.Synology.releases[1] | .url")
  else
    URL=$(echo $JSON | jq -r ".nas.Synology.releases[0] | .url")
  fi

With this:

URL=$(echo "${JSON}" | jq -r '.nas.Synology.releases[] | select(.build=="linux-'"${CPU}"'") | .url')
2 Likes

Looks like the if statement needs to be adjusted…

There should no longer be an if statement. You were supposed to replace the entire if statement with the single line starting with URL=…

In any case, you are running into an issue with the synopkg install command. Can you check /var/log/messages to see if there are any clues in there as to why it failed?

The version it’s downloading and trying to install is 1.18.0.1944-xxxxxx which is older than the current installed version of 1.18.1.1973-xxxx.

I think I managed to get everything up and running - but it looks like it’s only hitting the Public update channel. Any way to have it respect the setting in the “Server update Channel” field?

You might be downloading from the public channel, not the PlexPass.

Change the channel in the URL line to plexpass if you want the beta’s.
Not sure how to get it to poll the current setting but that would be swell.

url=$(echo “https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=$token”)

Figured it out. Not every variable has [ ] 's around it. Make sure the variables in the script match what the notification is looking for.

@trent.curtis Change this line:

if [ "${NEW_VERSION}" != "${CURRENT_VERSION}" ] ; then

To this:

if [[ "${NEW_VERSION}" > "${CURRENT_VERSION}" ]]; then