├── README.md └── plexupdate.sh /README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | Automatically update Plex Media Server on Synology NAS 3 | 4 | # How to 5 | Download the script and put it into a Scheduled Task 6 | ---Setup Download Script--- 7 | ssh into your nas 8 | execute: 9 | mkdir /volume1/Scripts 10 | wget https://github.com/martinorob/plexupdate/raw/master/plexupdate.sh 11 | 12 | ---Setup Update Scheduler--- 13 | #Comment: Go back to Synology Console 14 | Open Control Panel 15 | Open Task Scheduler 16 | Click Create ... Scheduled Task ... User-defined script 17 | Enter Task as Update Plex 18 | Click Schedule Tab 19 | Change Schedule to fit needs 20 | Click Task Settings Tab 21 | Enter User-defined script as bash /volume1/Scripts/plexupdate.sh 22 | Click OK 23 | 24 | Thanks to https://forums.plex.tv/u/j0nsplex 25 | 26 | # Todo 27 | Merge with 28 | https://gist.github.com/seanhamlin/dcde16a164377dca87a798a4c2ea051c 29 | https://forums.plex.tv/t/script-to-auto-update-plex-on-synology-nas-rev4/479748/36?u=martino 30 | -------------------------------------------------------------------------------- /plexupdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to automagically update Plex Media Server on Synology NAS 4 | # 5 | # Must be run as root. 6 | # 7 | # @author @martinorob https://github.com/martinorob 8 | # https://github.com/martinorob/plexupdate/ 9 | 10 | #!/bin/bash 11 | mkdir -p /tmp/plex/ > /dev/null 2>&1 12 | token=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+') 13 | url=$(echo "https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=$token") 14 | jq=$(curl -s ${url}) 15 | newversion=$(echo $jq | jq -r .nas.Synology.version) 16 | echo New Ver: $newversion 17 | curversion=$(synopkg version "Plex Media Server") 18 | echo Cur Ver: $curversion 19 | if [ "$newversion" != "$curversion" ] 20 | then 21 | echo New Vers Available 22 | /usr/syno/bin/synonotify PKGHasUpgrade '{"[%HOSTNAME%]": $(hostname), "[%OSNAME%]": "Synology", "[%PKG_HAS_UPDATE%]": "Plex", "[%COMPANY_NAME%]": "Synology"}' 23 | CPU=$(uname -m) 24 | url=$(echo "${jq}" | jq -r '.nas.Synology.releases[] | select(.build=="linux-'"${CPU}"'") | .url') 25 | /bin/wget $url -P /tmp/plex/ 26 | /usr/syno/bin/synopkg install /tmp/plex/*.spk 27 | sleep 30 28 | /usr/syno/bin/synopkg start "Plex Media Server" 29 | rm -rf /tmp/plex/* 30 | else 31 | echo No New Ver 32 | fi 33 | exit 34 | --------------------------------------------------------------------------------