Created
September 19, 2021 17:43
-
-
Save M-D-M/9e670790029922e83656bf2bd2d3c579 to your computer and use it in GitHub Desktop.
Update Plex Server Manually
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
## PLEX_URL change 2016/08/01 | |
## LATEST_URL change to python script | |
## | |
EXIT_CODE=0 | |
LATEST_URL= | |
PLEX_URL="https://plex.tv/api/downloads/1.json?_=1470076305698" | |
JSON_VAL_LOC='["computer"]["Linux"]["releases"][0]["url"]' | |
. /var/tmp/share/src/ENV.bash | |
. /var/tmp/share/src/UTIL_18.04.bash | |
main() { | |
if [[ $ENV_isRoot == FALSE ]]; then | |
ENV_err "This script must be run under root." | |
UTIL_notify "Attempt to run root script without root!" | |
EXIT_CODE=1 | |
else | |
checkPlexVersion | |
fi | |
} | |
checkPlexVersion() { | |
ENV_log "Checking installed version..." | |
INSTALLED_VER=`apt-show-versions -p plexmediaserver | awk '{print $2}'` | |
ENV_log "Installed version -- $INSTALLED_VER" | |
ENV_log "Checking version on plex.tv website..." | |
# LATEST_URL=`curl -s ${PLEX_URL} | egrep -io 'https.*plexmediaserver_.*amd64.deb'` | |
JSON_DATA=$(curl -s ${PLEX_URL}) | |
LATEST_URL=$(UTIL_grabJSONValue "$JSON_DATA" "$JSON_VAL_LOC") | |
LATEST_VER=`echo $LATEST_URL | awk -F'/' '{print $5}'` | |
ENV_log "Latest version available on plex.tv website -- $LATEST_VER" | |
if [[ $INSTALLED_VER == $LATEST_VER ]]; then | |
ENV_log "Latest version already installed. Exiting." | |
EXIT_CODE=1 | |
else | |
downloadAndInstallPlex | |
fi | |
} | |
downloadAndInstallPlex() { | |
ENV_log "New version $LATEST_VER found -- downloading..." | |
PLEX_DEB=`echo $LATEST_URL | awk -F'/' '{print $6}'` | |
wget -q -O /tmp/$PLEX_DEB $LATEST_URL | |
ENV_log "File saved to /tmp/$PLEX_DEB" | |
dpkg -i /tmp/$PLEX_DEB | |
} | |
main | |
exit $EXIT_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment