Updater-plex.sh
· 2.6 KiB · Bash
Eredeti
#!/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"
| 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 | |
| 16 | VERT="\\033[0;32m" |
| 17 | VERTG= |
| 18 | NORMAL="\\033[0;39m" |
| 19 | ROUGE="\\033[0;31m" |
| 20 | ROSE="\\033[1;35m" |
| 21 | BLEU="\\033[0;34m" |
| 22 | BLANC="\\033[0;02m" |
| 23 | BLANCLAIR="\\033[0;08m" |
| 24 | JAUNE="\\033[0;33m" |
| 25 | CYAN="\\033[0;36m" |
| 26 | ORANGE=$(tput setaf 208) |
| 27 | GRIS=$(tput setaf 8) |
| 28 | BOLD=$(tput bold) |
| 29 | Underline=$(tput sgr 0 1) |
| 30 | NOC=$(tput sgr0) |
| 31 | NC=$(tput sgr0) |
| 32 | |
| 33 | # Check Current installed version and exit if latest is already installed |
| 34 | service=plex |
| 35 | VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)') |
| 36 | |
| 37 | if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi |
| 38 | |
| 39 | VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))') |
| 40 | |
| 41 | echo -e "\n$VERT Checking Plex version ...\n" |
| 42 | echo -e "$JAUNE Version installed = $VersionInstalled" |
| 43 | echo -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 | |
| 46 | if [ $VersionAvailable = $VersionInstalled ]; then echo -e "\n Plex Media Server is already up-to-date $NC ;) Bye! "; exit; fi |
| 47 | echo -e "\n$VERT Downloading new Version --> $ORANGE$VersionAvailable \n $GRIS" |
| 48 | # Download latest installation package to /tmp folder |
| 49 | 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 |
| 50 | echo -e "$ORANGE Installation in progress ...$GRIS\n" |
| 51 | # Stop Plex Service before updating |
| 52 | sudo service plexmediaserver stop 2> /dev/null |
| 53 | # Install latest version |
| 54 | 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 |
| 55 | # ReStart Plex Service |
| 56 | sudo service plexmediaserver start &> /dev/null |
| 57 | |
| 58 | echo -e "$JAUNE Checking Proccess" |
| 59 | pgrep 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 |
| 63 | rm /tmp/plexmediaserver_* |
| 64 | echo -e "\n$VERT Plexmediaserver Updated [ $BOLD✔ $VERT] $NC Music is life !\n" |
| 65 |