Advertisement
Guest User

Libreelec Plexpass plex-update.sh

a guest
Dec 7th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | None | 0 0
  1. #!/bin/sh
  2. . /storage/.config/plex.conf
  3. LD_LIBRARY_PATH=/usr/lib
  4. PLEX_TOKEN=REPLACE_WITH_YOUR_PLEXPASS_TOKEN
  5.  
  6. PLEX_VERSION=$( curl -s "https://plex.tv/api/downloads/5.json?channel=plexpass" -H "X-Plex-Token: $PLEX_TOKEN" | python3 -c "import sys, json; print(json.load(sys.stdin)['computer']['Linux']['releases'][5]['url'])" | awk '{split($0,a,"plexmediaserver-"); print a[2]}' | awk '{split($0,a,".x86_64.rpm"); print a[1]}')
  7. PLEX_URL=$( curl -s "https://plex.tv/api/downloads/5.json?channel=plexpass" -H "X-Plex-Token: $PLEX_TOKEN" | python3 -c "import sys, json; print(json.load(sys.stdin)['computer']['Linux']['releases'][5]['url'])")
  8. echo $PLEX_VERSION
  9.  
  10. install_plex() {
  11.     mkdir -p /tmp/runplex ; cd /tmp/runplex
  12.     case `uname -m` in
  13.     x86_64)
  14.         echo "We're going to install $PLEX_VERSION"
  15.         systemctl stop plex
  16.         rm -rf /storage/.cache/app.plex.bak.2
  17.         mv /storage/.cache/app.plex.bak /storage/.cache/app.plex.bak.2
  18.         wget -q $PLEX_URL || exit 1
  19.         rpm2cpio plexmediaserver-$PLEX_VERSION.x86_64.rpm | cpio -di 2>/dev/null
  20.         ;;
  21.     armv7l)
  22.         wget -q https://downloads.plex.tv/plex-media-server-new/$1/debian/plexmediaserver_$1_armhf.deb || exit 1
  23.         ar -x *.deb
  24.         tar xf data.tar.*
  25.         ;;
  26.     esac
  27.     mv usr/lib/plexmediaserver $PLEX_MEDIA_SERVER_HOME
  28.     echo $PLEX_VERSION > $PLEX_MEDIA_SERVER_HOME/.plex_version
  29.     cd ~ ; rm -rf /tmp/runplex
  30.     systemctl start plex
  31. }
  32. if [ ! -x $PLEX_MEDIA_SERVER_HOME ]; then
  33.     echo "Plex directory does not exist, installing."
  34.     install_plex $PLEX_VERSION
  35. fi
  36. if [ -f $PLEX_MEDIA_SERVER_HOME/.plex_version ]; then
  37.     LOCAL_VERSION=\cat $PLEX_MEDIA_SERVER_HOME/.plex_version``
  38. fi
  39. if [ ! $PLEX_VERSION = $LOCAL_VERSION ] && [ ! $PLEX_VERSION = NA ] && [ ! $PLEX_VERSION = "" ]; then
  40.     echo "New version found, updating."
  41.     mv $PLEX_MEDIA_SERVER_HOME $PLEX_MEDIA_SERVER_HOME.bak
  42.     install_plex $PLEX_VERSION
  43.     else
  44.     echo "Plex up to date."
  45. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement