working on plex update script

pull/52/head
sparklyballs 9 years ago
parent 37eab12ea3
commit 5888cf11be

@ -11,6 +11,7 @@ RUN \
apt-get install -y \
avahi-daemon \
dbus \
less \
wget && \
# cleanup
apt-get clean && \

@ -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

Loading…
Cancel
Save