Skip to content

Commit 5888cf1

Browse files
committed
working on plex update script
1 parent 37eab12 commit 5888cf1

2 files changed

Lines changed: 43 additions & 11 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN \
1111
apt-get install -y \
1212
avahi-daemon \
1313
dbus \
14+
less \
1415
wget && \
1516
# cleanup
1617
apt-get clean && \

root/etc/cont-init.d/30-plex-update

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,55 @@
33
# opt out for autoupdates
44
[ "$ADVANCED_DISABLEUPDATES" ] && exit 0
55

6+
# set header for no preferences/token message
7+
[[ -e /tmp/no-token.nfo ]] && rm /tmp/no-token.nfo
8+
NOTOKEN_SET='/tmp/no-token.nfo'
9+
cat > "${NOTOKEN_SET}" <<-EOFTOKEN
610

7-
#The following error is not an error.
8-
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
911

12+
#####################################################
13+
# Login via webui and restart, because there was no #
14+
EOFTOKEN
1015

11-
#Get stuff from things.
12-
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' "/config/Library/Application Support/Plex Media Server/Preferences.xml" | sed "s/\".*//")
13-
[ -z "$PLEX_TOKEN" ] && echo "Plex token not avalible, please login " && exit 0
16+
# if preferences files doesn't exist, exit out
17+
if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then
18+
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
19+
# preference file found, possibly first startup. #
20+
#####################################################
1421

15-
[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION"
16-
if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi
1722

23+
EOFTOKEN
24+
less /tmp/no-token.nfo
25+
exit 0
26+
fi
27+
28+
# attempt to read plex token
29+
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \
30+
"/config/Library/Application Support/Plex Media Server/Preferences.xml" \
31+
| sed "s/\".*//")
1832

19-
#Start update rutine
33+
# if plex token isn't found, exit out
34+
if [ -z "$PLEX_TOKEN" ]; then
35+
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
36+
# plex token in the preferences file in config #
37+
#####################################################
38+
39+
40+
EOFTOKEN
41+
less /tmp/no-token.nfo
42+
exit 0
43+
fi
44+
45+
# determine installed version of plex
46+
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
2047

2148

49+
# start update routine
50+
51+
[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION"
52+
53+
if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi
54+
2255
if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then
2356
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 )
2457
echo "Target version: $VERSION set by: latest\plexpass"
@@ -31,9 +64,6 @@ else
3164
echo "Target version: $VERSION set by: manually"
3265
fi
3366

34-
35-
36-
3767
last=130
3868
if [[ "$VERSION" == "" ]]; then
3969
echo "ERROR: No version found, running installed version $INSTALLED"
@@ -49,5 +79,6 @@ elif [[ "$VERSION" != "$INSTALLED" ]]; then
4979
else
5080
echo "No need to update!"
5181
fi
82+
5283
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver
5384

0 commit comments

Comments
 (0)