Ultima attività 1 month ago

Revisione 94f41bb7c3330dc0247ca45d7e08dfac607fbb00

Updater-plex.sh Raw
1#!/bin/bash
2
3#####
4#
5# This Script will update Plex Media Server to the latest version for Debian/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 * * * /root/update-plexmediaserver.sh
11#
12# 2018 - Original by Matthieu Guerry
13# - Customised by erreur32
14###
15
16# Check Current installed version and exit if latest is already installed
17service=plex
18VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
19if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
20
21VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
22echo -e " Checking $service version ... "
23echo -e " Version installed = $VersionInstalled"
24echo -e " Version Available = $VersionAvailable"
25
26if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled) ... Bye! "; exit; fi
27
28echo -e " Download new Version $VersionAvailable"
29# Download latest installation package to /tmp folder
30curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/
31
32if [[ -z $(ps -ef |grep ${service}) ]]
33then
34 print "Hum service down !?! , anyway Service will updating\n"
35else
36 print "Plex is running, service will stop before Update...\n"
37fi
38# Stop Plex Service
39sudo service plexmediaserver stop
40# Install latest version
41sudo dpkg -i /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")')
42
43
44ps -ef | grep plex | grep -v grep
45[ $? -eq "0" ] && echo "Plex is running back :)" || echo "Plex is not running ... ;("
46
47# Start Plex Service
48echo -e " restart service Plex"
49sudo service plexmediaserver start
50
51# Remove installation package from /tmp folder
52rm /tmp/plexmediaserver_*
53