11#!/usr/bin/with-contenv bash
22
33# opt out for autoupdates
4- [ "$ADVANCED_DISABLEUPDATES" ] && exit 0
4+ [ "$ADVANCED_DISABLEUPDATES" ] && \
5+ exit 0
56
67# set header for no preferences/token message
7- [[ -e /tmp/no-token.nfo ]] && rm /tmp/no-token.nfo
8+ [[ -e /tmp/no-token.nfo ]] && \
9+ rm /tmp/no-token.nfo
810NOTOKEN_SET='/tmp/no-token.nfo'
911cat > "${NOTOKEN_SET}" <<-EOFTOKEN
1012
2830
2931# attempt to read plex token
3032PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \
31- "/config/Library/Application Support/Plex Media Server/Preferences.xml" \
32- | sed "s/\".*//")
33+ "/config/Library/Application Support/Plex Media Server/Preferences.xml" \
34+ | sed "s/\".*//")
3335
3436# if plex token isn't found, exit out
3537if [ -z "$PLEX_TOKEN" ]; then
@@ -39,7 +41,7 @@ cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
3941
4042
4143EOFTOKEN
42- less /tmp/no-token.nfo
44+ echo "$(cat /tmp/no-token.nfo)"
4345exit 0
4446fi
4547
@@ -49,7 +51,8 @@ INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
4951
5052# start update routine
5153
52- [ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION"
54+ [ "$PLEXPASS" ] && \
55+ echo "PLEXPASS is deprecated, please use VERSION"
5356
5457if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi
5558
6770
6871last=130
6972if [[ "$VERSION" == "" ]]; then
70- echo "VERSION variable not set, current installed version $INSTALLED"
73+ echo "VERSION variable not set, current installed version $INSTALLED"
7174elif [[ "$VERSION" != "$INSTALLED" ]]; then
72- echo "Upgrading from version: $INSTALLED to version: $VERSION"
73- while [[ $last -ne "0" ]]; do
75+ echo "Upgrading from version: $INSTALLED to version: $VERSION"
76+ while [[ $last -ne "0" ]]; do
7477 rm -f /tmp/plexmediaserver_*.deb
7578 curl -o /tmp/plexmediaserver_"${VERSION}"_amd64.deb -L \
76- "${PLEX_URL}/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
77- last=$?
79+ "${PLEX_URL}/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
80+ last=$?
7881 done
79- [[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && exit 0
80- apt-get remove --purge -y plexmediaserver
81- dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
82+ [[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && \
83+ exit 0
84+ apt-get remove --purge -y \
85+ plexmediaserver
86+ dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
87+
8288else
8389 echo "No need to update!"
8490fi
0 commit comments