Skip to content

Instantly share code, notes, and snippets.

@babelop babelop/plex-update.md
Last active Dec 16, 2016

Embed
What would you like to do?

Plex Automatic Updates (UNIX/RPM)

Installation

  1. Create a working directory for your updates, ex: /root/scripts/plex-update/
  2. Download a copy of plex-update.sh and make it executable
  3. Find your Plex Token
  4. nano plex-update.sh and set the PLEX_TOKEN variable
  5. Test the script ./plex-update.sh
  6. Schedule the updates regularly:

Advanced Topics

Monitoring for failed/stuck udpates with an NMS

You can serve status.xml to a local web-server and check its output with a network monitoring system.

cp -av $UPDATE_STATUS_FILE /srv/www/htdocs/ # Optional, for NMS

Use a web-check to search for the string 'size="1"', or alternatively
parse the xml file and use the XPath count(/MediaContainer[@size=1]).

#!/bin/bash
set -e
umask 0002
PLEX_TOKEN="INSERT_YOUR_TOKEN_HERE"
UPDATE_STATUS_FILE="plex-updates.xml"
curl --silent -o $UPDATE_STATUS_FILE "127.0.0.1:32400/updater/status?X-Plex-Token=$PLEX_TOKEN"
# cp -av $UPDATE_STATUS_FILE /srv/www/htdocs/ # Optional, for NMS
if [ -n "$(grep notify $UPDATE_STATUS_FILE)" ] ; then
echo "Update available!"
UPDATE_URL=$(grep -oPm1 "(?<=downloadURL=\")[^\"]+" $UPDATE_STATUS_FILE)
echo $UPDATE_URL
if [ -n "$UPDATE_URL" ] ; then
set -x
curl -L -o plex-update.rpm "$UPDATE_URL" && service plexmediaserver stop && rpm -Uvh plex-update.rpm
service plexmediaserver start
set +x
echo "Update finished."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.