From 5888cf11be6e5787d723cde9d2d0efacd296af21 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Sat, 2 Jul 2016 20:15:50 +0100 Subject: [PATCH] working on plex update script --- Dockerfile | 1 + root/etc/cont-init.d/30-plex-update | 53 +++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a0a385..1a2363f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN \ apt-get install -y \ avahi-daemon \ dbus \ + less \ wget && \ # cleanup apt-get clean && \ diff --git a/root/etc/cont-init.d/30-plex-update b/root/etc/cont-init.d/30-plex-update index aaea785..bf917e2 100644 --- a/root/etc/cont-init.d/30-plex-update +++ b/root/etc/cont-init.d/30-plex-update @@ -3,22 +3,55 @@ # opt out for autoupdates [ "$ADVANCED_DISABLEUPDATES" ] && exit 0 +# set header for no preferences/token message +[[ -e /tmp/no-token.nfo ]] && rm /tmp/no-token.nfo +NOTOKEN_SET='/tmp/no-token.nfo' +cat > "${NOTOKEN_SET}" <<-EOFTOKEN -#The following error is not an error. -INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver) +##################################################### +# Login via webui and restart, because there was no # +EOFTOKEN -#Get stuff from things. -PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' "/config/Library/Application Support/Plex Media Server/Preferences.xml" | sed "s/\".*//") -[ -z "$PLEX_TOKEN" ] && echo "Plex token not avalible, please login " && exit 0 +# if preferences files doesn't exist, exit out +if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then +cat >> "${NOTOKEN_SET}" <<-EOFTOKEN +# preference file found, possibly first startup. # +##################################################### -[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION" -if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi +EOFTOKEN +less /tmp/no-token.nfo +exit 0 +fi + +# attempt to read plex token +PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \ +"/config/Library/Application Support/Plex Media Server/Preferences.xml" \ +| sed "s/\".*//") -#Start update rutine +# if plex token isn't found, exit out +if [ -z "$PLEX_TOKEN" ]; then +cat >> "${NOTOKEN_SET}" <<-EOFTOKEN +# plex token in the preferences file in config # +##################################################### + + +EOFTOKEN +less /tmp/no-token.nfo +exit 0 +fi + +# determine installed version of plex +INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver) +# start update routine + +[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION" + +if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi + if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then VERSION=$(curl -s "https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 ) echo "Target version: $VERSION set by: latest\plexpass" @@ -31,9 +64,6 @@ else echo "Target version: $VERSION set by: manually" fi - - - last=130 if [[ "$VERSION" == "" ]]; then echo "ERROR: No version found, running installed version $INSTALLED" @@ -49,5 +79,6 @@ elif [[ "$VERSION" != "$INSTALLED" ]]; then else echo "No need to update!" fi + cp -v /defaults/plexmediaserver /etc/default/plexmediaserver