Skip to content

Instantly share code, notes, and snippets.

Last active Jun 22, 2021
What would you like to do?
# Script to Auto Update Plex on Synology NAS
# Must be run as root.
# @author Martino
# @see
mkdir -p /tmp/plex/
TOKEN=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+')
URL=$(echo "${TOKEN}")
JSON=$(curl -s ${URL})
NEW_VERSION=$(echo $JSON | jq -r .nas.Synology.version)
echo "New version: ${NEW_VERSION}"
CURRENT_VERSION=$(synopkg version "Plex Media Server")
echo "Current version: ${CURRENT_VERSION}"
if [ "${NEW_VERSION}" != "${CURRENT_VERSION}" ] ; then
echo "New version 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 $JSON | jq -r ".nas.Synology.releases[1] | .url")
URL=$(echo $JSON | jq -r ".nas.Synology.releases[0] | .url")
/bin/wget $URL -P /tmp/plex/
/usr/syno/bin/synopkg install /tmp/plex/*.spk
sleep 30
/usr/syno/bin/synopkg start "Plex Media Server"
rm -rf /tmp/plex
echo "Plex is up to date."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment