-
Notifications
You must be signed in to change notification settings - Fork 24
Add DSM7 Support #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
plexupdate-dsm7.sh
Outdated
|
||
#!/bin/bash | ||
mkdir -p /tmp/plex/ > /dev/null 2>&1 | ||
token=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "/var/packages/PlexMediaServer/home/Plex\ Media\ Server/Preferences.xml" since the "Plex" share is no longer being used now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't realise there was a new location for package data.
I had issues upgrading Plex after installing DSM 7, and based on posts by a Plex team member on their forums just updated permissions of the Plex
shared folder to give ownership to the new PlexMediaServer
system user. At that point the new Plex package was able to read library data and was working correctly.
Currently /var/packages/PlexMediaServer/home/Plex\ Media\ Server/Preferences.xml
looks like its missing the PlexOnlineToken
and just generally in a default state (missing other values). Does Plex need to be told to use this new directory for storing its data? Do I need to migrate the data from the existing Plex
shared folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding based on the forums is the Plex DSM 7 package installer migrates the "Plex" Share to the new system on install and then you can just delete the "Plex" share (and that's that I've gone ahead and done). Took me a while to dig up the new preferences location but the "Preferences.xml" has my token. cat /var/packages/PlexMediaServer/home/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+'
also returns my token.
I still can't figure out where the library databases have been migrated to though, as they don't seem to be with these files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I didn't realise the migration failure I experienced was a permissions error at first, so I manually uninstalled Plex and the installed the DSM 7 package, bypassing the migration.
Going to try and fix it, in the meantime I've updated the path. Thanks for bringing it to my attention!
EDIT: For anyone else who mistakenly bypassed the migration of the Plex
shared folder to the new application data location, refer to this post on the Plex forums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I've been doing some more exploring with the new Plex setup. "/volume1/@apphome/PlexMediaServer/Plex\ Media\ Server/Preferences.xml" seems to be an equally valid path. Not sure which one is better to use, but thought it worth noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! I noticed that not long after my comment. Thanks! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. I've swapped out the curversion and newversion lines with those mentioned above but am still getting
New Ver: 1.25.2.5319-c43dc0277
Cur Ver: 1.25.2.5319-7000
What should the latest and best script look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@divadiow I would just go with @Fifteen15Studios’s script, as it seems to have many improvements not implemented in this pull request (see #8 (comment)).
If you implemented the sed
or cut
commands we discussed here and it still doesn’t work, I would also want to make sure the script you edited is the one that is being run.
Also, you might consider running the commands manually, line by line, to see why it’s not transforming the version numbers correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @OverengineeredNetwork well for a start I was running the wrong damn script. I guess I didn't change the task location 🙄
anyway. It's running now with the seds but I was getting no result output in the script text. I changed the location of the resultfile and added a cat at the end and now my output to file and the subsequent email alert contains "no new version" as expected.
working script is this
#!/bin/bash
# Script to automagically update Plex Media Server on Synology NAS
#
# Must be run as root.
#
# @author @martinorob https://github.com/martinorob
# https://github.com/martinorob/plexupdate/
# Volume where Plex is installed
VOLUME=$(echo "/volume1")
# Location of temp folder for this script
tmpFolder="/volume1/Scripts"
resultFile=$tmpFolder/plexupdateresult.txt
# Get information we need
token=$(cat ${VOLUME}/PlexMediaServer/AppData/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+')
url=$(echo "https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=$token")
jq=$(curl -s ${url})
# Get version numbers
# For some reason the part after the dash changes, so exclude it
newversion=$(echo $jq | jq -r '.nas."Synology (DSM 7)".version'|sed 's/-.*//')
echo "New Ver: $newversion" > $resultFile
curversion=$(synopkg version "PlexMediaServer"|sed 's/-.*//')
echo "Cur Ver: $curversion" >> $resultFile
# Compare version numbers
if [ "$newversion" != "$curversion" ]
# New Version Available
then
/usr/syno/bin/synonotify PKGHasUpgrade '{"%PKG_HAS_UPDATE%": "Plex Media Server"}'
CPU=$(uname -m)
url=$(echo "${jq}" | jq -r '.nas."Synology (DSM 7)".releases[] | select(.build=="linux-'"${CPU}"'") | .url')
# Download the file
/bin/wget $url -P $tmpFolder/
# Get filename from URL
slashes=$(awk -F"/" '{print NF-1}' <<< "${url}")
filename=$(echo $url | cut -d '/' -f $(expr $slashes + 1))
# Install the file
/usr/syno/bin/synopkg install $tmpFolder/$filename >> $resultFile
sleep 30
/usr/syno/bin/synopkg start "Plex Media Server"
rm -rf $tmpFolder/*.spk
else
echo "No new version available" >> $resultFile
cat $resultFile
fi
exit
output has this
New Ver: 1.25.3.5409
Cur Ver: 1.25.3.5409
No new version available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to be on the lookout for that new version. I'm still on 1.25.2.5319. It'll be good to see if my script picks it up.
@OverengineeredNetwork I did leave in some changes that I made in my fork (like the VOLUME variable.) In my fork I have changed that path slightly from my last comment, too. Feel free to look at my fork of the project, as it includes many of the changes that you pointed out. https://github.com/Fifteen15Studios/plexupdate |
Oh! That's cool @Fifteen15Studios. I didn't see that. Thanks for linking it. Looks great. |
@Fifteen15Studios
Turns out, my package name for Plex is "PlexMediaServer" instead of "Plex Media Server". Could this be updated or do I have an abnormal package name for Plex? |
Also, what's the purpose of using the token when getting the latest updates for Plex? I tried without the token and was able to |
@starryknight64 I don't have this issue. My script works perfectly for me, as-is. If your package name is different, feel free to fork mine and change it in your fork, or simply download the script and change it in your local copy.
No idea why that is done. It wasn't my work, I simply forked it and made some minor changes. It was working, so I decided not to modify that part. Since it seems that this repository is not actively maintained (there has been absolutely no responses from the repo owner that I've seen) feel free to submit a pull request on my repo and I will merge the changes if the script still works properly with the changes. Unless someone else knows a reason to not remove that part. |
@Fifteen15Studios Before I consider forking, to confirm, when you type this command do you get back "Plex Media Server" or "PlexMediaServer"? Theoretically this should be your package name, unless I'm mistaken?
|
FWIW, I have the spaces in the package name on my system. Maybe it depends on whether you ever installed it via Package Center? |
@starryknight64 My package name definitely has the spaces. Just checked. |
@HolisticDeveloper That's likely it. I inadvertently did this when I upgraded it last year. I'll fix my pull request... |
@Fifteen15Studios It's just odd to me that this line would work for you then... oh well! :) |
Adds support for new DSM7 package. Also includes better version checking from #5.