docker-plex-wireguard/init/30_update_plex.sh

52 lines
1.7 KiB
Bash
Raw Normal View History

2015-05-10 10:50:00 +02:00
#!/bin/bash
# opt out for autoupdates
[ "$ADVANCED_DISABLEUPDATES" ] && exit 0
2015-05-10 10:50:00 +02:00
export DEBIAN_FRONTEND=noninteractive
2015-08-28 12:36:53 +02:00
while ! ping -c1 tools.linuxserver.io &>/dev/null; do :; done
2015-11-13 11:19:07 +00:00
#The following error is not an error.
2015-10-13 23:20:52 +02:00
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
2015-08-28 12:36:53 +02:00
#Get stuff from things.
2016-03-30 10:58:28 +02:00
PLEX_TOKEN=$(cat "/config/Library/Application Support/Plex Media Server/Preferences.xml" | sed -n 's/.*PlexOnlineToken="//p' | sed "s/\".*//")
[ -z PLEX_TOKEN ] && echo "Plex token not avalible, please login " && exit 0
PLEX_LATEST=$(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 )
2015-09-24 09:25:27 +02:00
[ "$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
#Start update rutine
2015-08-28 12:36:53 +02:00
2016-03-30 11:01:10 +02:00
if [[] "$VERSION" = latest || "$VERSION" = plexpass ]]; then
VERSION=$PLEX_LATEST
echo "Target version: $VERSION set by: latest\plexpass"
2015-08-28 12:36:53 +02:00
else
echo "Target version: $VERSION set by: manually"
2015-05-10 10:50:00 +02:00
fi
2015-08-28 12:36:53 +02:00
2015-08-28 12:36:53 +02:00
last=130
if [[ "$VERSION" == "" ]]; then
echo "ERROR: No version found, running installed version $INSTALLED"
elif [[ "$VERSION" != "$INSTALLED" ]]; then
2015-11-13 11:19:07 +00:00
echo "Upgrading from version: $INSTALLED to version: $VERSION"
2015-09-24 09:25:27 +02:00
while [[ $last -ne "0" ]]; do
rm -f /tmp/plexmediaserver_*.deb
wget -P /tmp "https://downloads.plex.tv/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
2015-09-24 09:25:27 +02:00
last=$?
2015-08-28 12:46:13 +02:00
done
2015-08-28 13:59:01 +02:00
apt-get remove --purge -y plexmediaserver
2016-03-30 10:31:32 +02:00
dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
2015-08-28 12:46:13 +02:00
else
2015-09-24 09:25:27 +02:00
echo "No need to update!"
2015-08-28 12:46:13 +02:00
fi
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver