Skip to content

Instantly share code, notes, and snippets.

Last active Dec 21, 2018
What would you like to do?
# This Script will update Plex Media Server to the latest version for Ubuntu
# To automatically check & update plex, run "crontab -e" and add the following lines
# # Check for Plex Media Server Updates every day @6:00 am
# 0 6 * * * /path/you/want/
# 2018 - Script by erreur32
# - inspired by Matthieu Guerry
ORANGE=$(tput setaf 208)
GRIS=$(tput setaf 8)
BOLD=$(tput bold)
Underline=$(tput sgr 0 1)
NOC=$(tput sgr0)
NC=$(tput sgr0)
# Check Current installed version and exit if latest is already installed
VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
VersionAvailable=$(curl -s "" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
echo -e "\n$VERT Checking Plex version ...\n"
echo -e "$JAUNE Version installed = $VersionInstalled"
echo -e "$JAUNE Version Available = $ORANGE$VersionAvailable"
#UrlNewVersion=$(curl -sS "" | grep -Po '(?<=url=\")(\S+)(?=\")')
if [ $VersionAvailable = $VersionInstalled ]; then echo -e "\n Plex Media Server is already up-to-date $NC ;) Bye! "; exit; fi
echo -e "\n$VERT Downloading new Version --> $ORANGE$VersionAvailable \n $GRIS"
# Download latest installation package to /tmp folder
curl -s "" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/ 2> /dev/null
echo -e "$ORANGE Installation in progress ...$GRIS\n"
# Stop Plex Service before updating
sudo service plexmediaserver stop 2> /dev/null
# Install latest version
sudo dpkg -i /tmp/$(curl -s "" | grep -Po '(?<=fileName=\")(\S+)(?=\")') &> /dev/null
# ReStart Plex Service
sudo service plexmediaserver start &> /dev/null
echo -e "$JAUNE Checking Proccess"
pgrep plex &> /dev/null && echo -e "$NC --> Plex is Running well $NC" || echo -e "$ORANGE Houston we have a problem ... Plex Not running ...$NC"
#pgrep plex || echo -e "$ORANGE Houston we have a problem ... Plex Not running ...$NC"
# Remove installation package from /tmp folder
rm /tmp/plexmediaserver_*
echo -e "\n$VERT Plexmediaserver Updated [ $BOLD$VERT] $NC Music is life !\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment