You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docker-plex/root/etc/cont-init.d/50-plex-update

105 lines
3.2 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/usr/bin/with-contenv bash
# set no update message
[[ -e /tmp/no-version.nfo ]] && \
rm /tmp/no-version.nfo
NOVERSION_SET='/tmp/no-version.nfo'
cat > "${NOVERSION_SET}" <<-EOFVERSION
#######################################################
# Update routine will not run because you havent set #
# the VERSION variable, for more information checkout #
#  https://github.com/linuxserver/docker-plex #
#######################################################
EOFVERSION
# test for no version set or opt out for autoupdates
if [ -z "$VERSION" -o "$VERSION" == "0" -o ! -z "$ADVANCED_DISABLEUPDATES" ]; then
echo "$(cat /tmp/no-version.nfo)"
exit 0
fi
# 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
#####################################################
# Login via the webui at http://<ip>:32400/web #
# and restart the docker, because there was no #
EOFTOKEN
# 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. #
#####################################################
EOFTOKEN
echo "$(cat /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/\".*//")
# if plex token isn't found, exit out
if [ -z "$PLEX_TOKEN" ]; then
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
# plex token found in the preference file #
#####################################################
EOFTOKEN
echo "$(cat /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 deprecated please use version latest"; fi
if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then
VERSION=$(curl -s "${PLEX_URL}/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 to: latest\plexpass"
elif [[ "$VERSION" = public ]]; then
VERSION=$(curl -s "${PLEX_URL}/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token="| cut -d "/" -f 5 )
echo "Target version: $VERSION set to: public"
else
echo "Target version: $VERSION set to: manual"
fi
last=130
if [[ "$VERSION" != "$INSTALLED" ]]; then
echo "Upgrading from version: $INSTALLED to version: $VERSION"
while [[ $last -ne "0" ]]; do
rm -f /tmp/plexmediaserver_*.deb
curl -o /tmp/plexmediaserver_"${VERSION}"_amd64.deb -L \
"${PLEX_URL}/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
last=$?
done
[[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && \
exit 0
apt-get remove --purge -y \
plexmediaserver
dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
else
echo "No need to update!"
fi
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver