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+
2255if [[ "$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"
3164 echo "Target version: $VERSION set by: manually"
3265fi
3366
34-
35-
36-
3767last=130
3868if [[ "$VERSION" == "" ]]; then
3969 echo "ERROR: No version found, running installed version $INSTALLED"
@@ -49,5 +79,6 @@ elif [[ "$VERSION" != "$INSTALLED" ]]; then
4979else
5080 echo "No need to update!"
5181fi
82+
5283cp -v /defaults/plexmediaserver /etc/default/plexmediaserver
5384
0 commit comments