Last active
May 6, 2021 00:21
-
-
Save davenicoll/06048fd709234f738f723fe884fb2379 to your computer and use it in GitHub Desktop.
Automatically update plex on synology NAS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p /tmp/plex/ > /dev/null 2>&1 | |
rm -rf /tmp/plex/* > /dev/null 2>&1 | |
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") | |
jq=$(curl -s ${url}) | |
newversion=$(echo $jq | jq -r .nas.Synology.version) | |
echo New Ver: $newversion | |
curversion=$(synopkg version "Plex Media Server") | |
echo Cur Ver: $curversion | |
if [ "$newversion" != "$curversion" ] | |
then | |
echo New Version Available | |
/usr/syno/bin/synonotify PKGHasUpgrade '{"%PKG_HAS_UPDATE%": "Plex"}' | |
CPU=$(uname -m) | |
url=$(echo "${jq}" | 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 No New Version | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
crontab:
rev1 fix
rev2 notification
rev3 cpu based url (x86 or x32)
rev4 extract token in better way
rev5 compatible with all CPU
rev6 typo
IMPORTANT:
Change the
Trust Level
toAny publisher
inPackage Center > Settings
and
Add Plex key https://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/?_ga=2.162387836.1194402430.1571755454-1617362326.1543598076
Source: https://forums.plex.tv/t/script-to-auto-update-plex-on-synology-nas-rev6/479748