# Plex Pass Update Script for Debian (Ubuntu)

**URL:** <https://forums.plex.tv/t/plex-pass-update-script-for-debian-ubuntu/227337>\
**Category:** General Discussions\
**Created:** [February 28, 2018, 6:38pm UTC](https://forums.plex.tv/t/plex-pass-update-script-for-debian-ubuntu/227337 "2018-02-28T18:38:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngpitt](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ngpitt/32/86206_2.png) [@ngpitt](https://forums.plex.tv/u/ngpitt)\
**Post date:** [February 28, 2018, 6:38pm UTC](https://forums.plex.tv/t/plex-pass-update-script-for-debian-ubuntu/227337/1 "2018-02-28T18:38:44Z")

</div>

For anyone else who would like to automate updating their Debian (Ubuntu) servers to the latest Plex Pass version, here’s my automation script (works great with `cron`, uses `curl`, `jq`, and `dpkg`):

```
#!/bin/bash

set -e

USERNAME="username"
PASSWORD="password"
DISTRO="ubuntu"
BUILD="linux-ubuntu-x86_64"

CLIENT_ID="$USERNAME-plex-updater-v1"
PRODUCT="Plex Updater"
VERSION="v1"
SIGNIN_URL="https://plex.tv/users/sign_in.json"
RELEASES_URL="https://plex.tv/api/downloads/1.json?channel=plexpass"
DOWNLOAD_DIR="/tmp"

echo "Signing in to plex.tv..."

SIGNIN_RESPONSE=$(curl -s \
    -H "X-Plex-Client-Identifier: $CLIENT_ID" \
    -H "X-Plex-Product: $PRODUCT" \
    -H "X-Plex-Version: $VERSION" \
    -d "user%5Blogin%5D=$USERNAME" \
    -d "user%5Bpassword%5D=$PASSWORD" \
    $SIGNIN_URL)

TOKEN=$(jq -r ".user.authentication_token" <<< $SIGNIN_RESPONSE)

echo "Getting releases..."

RELEASES_RESPONSE=$(curl -s \
    -H "X-Plex-Client-Identifier: $CLIENT_ID" \
    -H "X-Plex-Product: $PRODUCT" \
    -H "X-Plex-Version: $VERSION" \
    -H "X-Plex-Token: $TOKEN" \
    $RELEASES_URL)

CURRENT_VERSION=$(jq -r ".computer.Linux.version" <<< $RELEASES_RESPONSE)
INSTALLED_VERSION=$(dpkg-query --showformat='${Version}' --show plexmediaserver)

echo "Current version: $CURRENT_VERSION"
echo "Installed version: $INSTALLED_VERSION"

if ["$CURRENT_VERSION" == "$INSTALLED_VERSION"]
then
    echo "Plex is up-to-date."
    exit 0
fi

echo "Updating Plex..."

PACKAGE_URL=$(jq -r ".computer.Linux.releases[] | select(.distro == \"$DISTRO\") | select(.build == \"$BUILD\").url" <<< $RELEASES_RESPONSE)
PACKAGE_NAME=$(basename $PACKAGE_URL)
PACKAGE_PATH="$DOWNLOAD_DIR/$PACKAGE_NAME"

curl \
    -H "X-Plex-Client-Identifier: $CLIENT_ID" \
    -H "X-Plex-Product: $PRODUCT" \
    -H "X-Plex-Version: $VERSION" \
    -H "X-Plex-Token: $TOKEN" \
    -o $PACKAGE_PATH $PACKAGE_URL

dpkg -i $PACKAGE_PATH 

echo "Plex successfully updated."

```

Maybe there’s a better version of this floating around somewhere else, however I figured it couldn’t hurt to post.

---

<div class="post-metadata">

**Author:** ![aboron](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/aboron/32/83901_2.png) [@aboron](https://forums.plex.tv/u/aboron)\
**Post date:** [March 2, 2018, 2:48pm UTC](https://forums.plex.tv/t/plex-pass-update-script-for-debian-ubuntu/227337/2 "2018-03-02T14:48:48Z")

</div>

Nice work, thanks!

FYI for anyone running plex in a minimal ubuntu system like mine, “jq” needs to be installed before the script will work.  
It’s just:  
`apt-get install jq`  
The other requirements were already installed.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 8, 2020, 12:41am UTC](https://forums.plex.tv/t/plex-pass-update-script-for-debian-ubuntu/227337/3 "2020-01-08T00:41:23Z")

</div>


