#!/bin/bash ##### # # 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/update-plexmediaserver.sh # # 2018 - Script by erreur32 # - inspired by Matthieu Guerry ### VERT="\\033[0;32m" VERTG= NORMAL="\\033[0;39m" ROUGE="\\033[0;31m" ROSE="\\033[1;35m" BLEU="\\033[0;34m" BLANC="\\033[0;02m" BLANCLAIR="\\033[0;08m" JAUNE="\\033[0;33m" CYAN="\\033[0;36m" 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 service=plex VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)') if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | 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 "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | 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 "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | 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 "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | 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"