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.
54 lines
1.9 KiB
54 lines
1.9 KiB
9 years ago
|
#!/usr/bin/with-contenv bash
|
||
9 years ago
|
|
||
|
# opt out for autoupdates
|
||
|
[ "$ADVANCED_DISABLEUPDATES" ] && exit 0
|
||
|
|
||
9 years ago
|
|
||
9 years ago
|
#The following error is not an error.
|
||
9 years ago
|
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
|
||
10 years ago
|
|
||
9 years ago
|
|
||
|
#Get stuff from things.
|
||
9 years ago
|
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' "/config/Library/Application Support/Plex Media Server/Preferences.xml" | sed "s/\".*//")
|
||
9 years ago
|
[ -z "$PLEX_TOKEN" ] && echo "Plex token not avalible, please login " && exit 0
|
||
9 years ago
|
|
||
9 years ago
|
[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION"
|
||
9 years ago
|
if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi
|
||
|
|
||
9 years ago
|
|
||
9 years ago
|
#Start update rutine
|
||
10 years ago
|
|
||
9 years ago
|
|
||
9 years ago
|
if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then
|
||
9 years ago
|
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 )
|
||
9 years ago
|
echo "Target version: $VERSION set by: latest\plexpass"
|
||
9 years ago
|
elif [[ "$VERSION" = public ]]; then
|
||
|
VERSION=$(curl -s "https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token="| cut -d "/" -f 5 )
|
||
|
echo "Target version: $VERSION set by: public"
|
||
9 years ago
|
elif [[ -z "$VERSION" ]]; then
|
||
9 years ago
|
echo "Target version: Version not set, Defaulting to supplied version"
|
||
10 years ago
|
else
|
||
9 years ago
|
echo "Target version: $VERSION set by: manually"
|
||
10 years ago
|
fi
|
||
10 years ago
|
|
||
9 years ago
|
|
||
|
|
||
|
|
||
10 years ago
|
last=130
|
||
9 years ago
|
if [[ "$VERSION" == "" ]]; then
|
||
|
echo "ERROR: No version found, running installed version $INSTALLED"
|
||
|
elif [[ "$VERSION" != "$INSTALLED" ]]; then
|
||
9 years ago
|
echo "Upgrading from version: $INSTALLED to version: $VERSION"
|
||
9 years ago
|
while [[ $last -ne "0" ]]; do
|
||
|
rm -f /tmp/plexmediaserver_*.deb
|
||
9 years ago
|
wget -P /tmp "https://downloads.plex.tv/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
|
||
9 years ago
|
last=$?
|
||
10 years ago
|
done
|
||
10 years ago
|
apt-get remove --purge -y plexmediaserver
|
||
9 years ago
|
dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
|
||
10 years ago
|
else
|
||
9 years ago
|
echo "No need to update!"
|
||
10 years ago
|
fi
|
||
9 years ago
|
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver
|
||
9 years ago
|
|