Created
November 17, 2019 22:25
-
-
Save patillacode/d6239616141a1db05d10128164b5d2db to your computer and use it in GitHub Desktop.
Small bash script that updates your Plex Media Server (Linux) automatically - with a nice output for when running manually!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tput setaf 1 && tput bold | |
echo "Stopping the Plex server" | |
sudo service plexmediaserver stop | |
tput sgr0 && tput setaf 4 | |
echo "Moving to /tmp/ ..." | |
cd /tmp/ | |
echo "Downloading latest version of Plex server..." | |
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget > /dev/null 2>&1 | |
file_name=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")') | |
tput setaf 6 | |
echo -ne "\nInstalling new image: " | |
tput sgr0 && tput bold | |
echo -e "$file_name\n" | |
tput sgr0 && tput setaf 6 | |
sudo dpkg -i $file_name | |
tput setaf 1 && tput bold | |
echo -e "\nRestarting Plex server..." | |
sudo service plexmediaserver start | |
tput op | |
tput setaf 5 | |
echo -n "Checking new server is running..." | |
systemctl is-active --quiet plexmediaserver && tput setaf 2 && tput bold && echo -e " Running!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment