Ultima attività 1 month ago

Revisione e4218120b7c1e0355568d7eb0424188d6cd2ece1

Updater-plex.sh Raw
1#!/bin/bash
2
3#####
4#
5# This Script will update Plex Media Server to the latest version for Ubuntu
6#
7# To automatically check & update plex, run "crontab -e" and add the following lines
8#
9# # Check for Plex Media Server Updates every day @6:00 am
10# 0 6 * * * /path/you/want/update-plexmediaserver.sh
11#
12# 2018 - Script by erreur32
13# - inspired by Matthieu Guerry
14###
15
16VERT="\\033[0;32m"
17VERTG=
18NORMAL="\\033[0;39m"
19ROUGE="\\033[0;31m"
20ROSE="\\033[1;35m"
21BLEU="\\033[0;34m"
22BLANC="\\033[0;02m"
23BLANCLAIR="\\033[0;08m"
24JAUNE="\\033[0;33m"
25CYAN="\\033[0;36m"
26ORANGE=$(tput setaf 208)
27GRIS=$(tput setaf 8)
28BOLD=$(tput bold)
29Underline=$(tput sgr 0 1)
30NOC=$(tput sgr0)
31NC=$(tput sgr0)
32
33# Check Current installed version and exit if latest is already installed
34service=plex
35VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
36
37if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
38
39VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
40
41echo -e "\n$VERT Checking Plex version ...\n"
42echo -e "$JAUNE Version installed = $VersionInstalled"
43echo -e "$JAUNE Version Available = $ORANGE$VersionAvailable"
44#UrlNewVersion=$(curl -sS "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")')
45
46if [ $VersionAvailable = $VersionInstalled ]; then echo -e "\n Plex Media Server is already up-to-date $NC ;) Bye! "; exit; fi
47echo -e "\n$VERT Downloading new Version --> $ORANGE$VersionAvailable \n $GRIS"
48# Download latest installation package to /tmp folder
49curl -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
50echo -e "$ORANGE Installation in progress ...$GRIS\n"
51# Stop Plex Service before updating
52sudo service plexmediaserver stop 2> /dev/null
53# Install latest version
54sudo 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
55# ReStart Plex Service
56sudo service plexmediaserver start &> /dev/null
57
58echo -e "$JAUNE Checking Proccess"
59pgrep plex &> /dev/null && echo -e "$NC --> Plex is Running well $NC" || echo -e "$ORANGE Houston we have a problem ... Plex Not running ...$NC"
60#pgrep plex || echo -e "$ORANGE Houston we have a problem ... Plex Not running ...$NC"
61
62# Remove installation package from /tmp folder
63rm /tmp/plexmediaserver_*
64echo -e "\n$VERT Plexmediaserver Updated [ $BOLD$VERT] $NC Music is life !\n"
65