Остання активність 1 month ago

Версія 2b66ae03fea0d82bf2290711a179383199ec17d6

Updater-plex.sh Неформатований
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+)')
19VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
20echo -e " Checking Plex version ... "
21echo -e " Version installed = $VersionInstalled"
22echo -e " Version Available = $VersionAvailable"
23
24if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
25if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled) ... Bye! "; exit; fi
26
27echo -e " Download new Version $VersionAvailable"
28# Download latest installation package to /tmp folder
29curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/
30
31if [[ -z $(ps -ef |grep ${service}) ]]
32then
33 print "Hum service down !?! , anyway Service will updating\n"
34else
35 print "Plex is running, service will stop before Update...\n"
36fi
37# Stop Plex Service
38sudo service plexmediaserver stop
39# Install latest version
40sudo dpkg -i /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")')
41
42
43ps -ef | grep plex | grep -v grep
44[ $? -eq "0" ] && echo "Plex is running back :)" || echo "Plex is not running ... ;("
45
46# Start Plex Service
47echo -e " restart service Plex"
48sudo service plexmediaserver start
49
50# Remove installation package from /tmp folder
51rm /tmp/plexmediaserver_*
52