Saturday, September 23, 2017

Plex Updater for Ubuntu

As I don't like changing disks, I have been working on migrating my physical DVD/Blu-ray to being on Plex. One thing that has seemed a bane was of this is the manual update process for Ubuntu Server. For this, I decided it was time for me to start learning to make my own shell scripts.

For this script, you pipe in the full path to the .DEB file, then the script handles the WGET, DPKG and RM of the file once complete. While this may not allow the 'Title Banner' section to show nicely, it does (IMHO) give a nice header when run.

Usage: ./updateplex.sh FQDN_DEB_DOWNLOAD_PATH
#!/bin/bash

# Set Color Variables
COLOR_NONE='\033[0m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_BROWN='\033[0;33m'
COLOR_BLUE='\033[0;34m'
COLOR_LBLUE='\033[1;34m'

# Take URL and get the .DEB filename
URL=$1
URL_NOPRO=${URL:8}
URL_REL=${URL_NOPRO#*/}
PLEXFILE=${URL_NOPRO#*/plex-media-server/*/}

#Clear the screen
clear

#Title Banner
TITLE_COLOR=$COLOR_BROWN
echo -e ${TITLE_COLOR}+---------------------------------------------------------+${COLOR_NONE}
echo -e ${TITLE_COLOR} ___ \ _ \ \ \ ____ _ \ _ \ \ \ _ \ _ ___ \ ___ \ ____ ___ ____ ____ ${COLOR_NONE}
echo -e ${TITLE_COLOR} \|__\] \| \ \ \ \|___ \ \\/ \ \ \ \ \| \ \| \|__] \| \ \\ \|__\| \ \| \ \|___ \|__/ ${COLOR_N$
echo -e ${TITLE_COLOR} \| \ \ \ \|___ \|___ _/\\_ \ \ \ \|__\| \| \ \ \ \|__/ \| \ \| \ \| \ \|___ \| \ \\ ${COLOR_N$
echo
echo -e ${TITLE_COLOR}+---------------------------------------------------------+${COLOR_NONE}
echo

echo -e ${COLOR_GREEN}SOURCE\:${COLOR_NONE} $URL
echo -e ${COLOR_GREEN}DEB FILE\:${COLOR_NONE} $PLEXFILE
echo

#Download the file
echo -e ${COLOR_GREEN}===========================${COLOR_NONE}
echo -e ${COLOR_GREEN}= DOWNLOADING PLEX UPDATE =${COLOR_NONE}
echo -e ${COLOR_GREEN}===========================${COLOR_NONE}
echo
wget $URL

#Install the Plex file
echo -e ${COLOR_GREEN}==========================${COLOR_NONE}
echo -e ${COLOR_GREEN}= INSTALLING PLEX UPDATE =${COLOR_NONE}
echo -e ${COLOR_GREEN}==========================${COLOR_NONE}
echo
sudo dpkg -i $PLEXFILE

#Remove the .DEB file
echo -e ${COLOR_GREEN}==========================${COLOR_NONE}
echo -e ${COLOR_GREEN}= REMOVING PLEX DEB FILE =${COLOR_NONE}
echo -e ${COLOR_GREEN}==========================${COLOR_NONE}
echo
rm $PLEXFILE

echo -e ${COLOR_GREEN}========================${COLOR_NONE}
echo -e ${COLOR_GREEN}= PLEX UPDATE COMPLETE =${COLOR_NONE}
echo -e ${COLOR_GREEN}========================${COLOR_NONE}
echo

 Output
image of 'updateplex.sh' output


No comments:

Post a Comment