Last active
October 31, 2019 22:56
-
-
Save szhajdu/481c1a1ab08f4ddfcef8a802b05ba3c6 to your computer and use it in GitHub Desktop.
Download and 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 /volume1/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 "Latest Version: $newversion" | |
curversion=$(synopkg version "Plex Media Server") | |
echo "Current Version: $curversion" | |
if [ "$newversion" != "$curversion" ] | |
then | |
echo "New Version is available" | |
/usr/syno/bin/synonotify PKGHasUpgrade '{"[%HOSTNAME%]": $(hostname), "[%OSNAME%]": "Synology", "[%PKG_HAS_UPDATE%]": "Plex", "[%COMPANY_NAME%]": "Synology"}' | |
cpu=$(uname -m) | |
if [ "$cpu" = "x86_64" ]; then | |
url=$(echo "$jq" | jq -r ".nas.Synology.releases[1] | .url") | |
else | |
url=$(echo "$jq" | jq -r ".nas.Synology.releases[0] | .url") | |
fi | |
/bin/wget "$url" -P /volume1/tmp/plex/ | |
/usr/syno/bin/synopkg install /volume1/tmp/plex/*.spk && /usr/syno/bin/synopkg start "Plex Media Server" && rm -rf /volume1/tmp/plex/* | |
else | |
echo "Plex is up to date" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment