11#!/usr/bin/with-contenv bash
22
3- # determine architecture to gaurd arm variants in deployment stage 1
4- ARCH=$(arch)
5- if [[ "${ARCH}" == armv* ]]; then
6- echo "This is armv7, upgrading Plex is not supported yet"
7- exit 0
8- elif [[ "${ARCH}" == "aarch64" ]]; then
9- echo "This is aarch64, upgrading Plex is not supported yet"
10- exit 0
11- fi
12-
133# If docker manages versioning exit
144if [ "${VERSION}" ] && [ "${VERSION}" == 'docker' ]; then
155 echo "Docker is used for verisoning skip update check"
@@ -22,7 +12,7 @@ if (dpkg --get-selections plexmediaserver | grep -wq "install"); then
2212else
2313echo "for some reason plex doesn't appear to be installed, pulling a new copy and exiting out of update script"
2414curl -o /tmp/plexmediaserver.deb -L \
25- "${PLEX_INSTALL} " && \
15+ "${PLEX_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb " && \
2616dpkg -i --force-confold /tmp/plexmediaserver.deb
2717rm -f /tmp/plexmediaserver.deb
2818exit 0
@@ -101,10 +91,16 @@ INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' plexmediaserver)
10191
10292# start update routine
10393if [[ "${VERSION,,}" = latest ]] || [[ "${VERSION,,}" = plexpass ]] || [[ "$PLEXPASS" == "1" ]]; then
104- REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
94+ if [[ "${PLEX_ARCH}" = amd64 ]]; then
95+ PLEX_URL_ARCH="x86_64"
96+ elif [[ "${PLEX_ARCH}" = armhf ]]; then
97+ PLEX_URL_ARCH="armv7hf_neon"
98+ elif [[ "${PLEX_ARCH}" = arm64 ]]; then
99+ PLEX_URL_ARCH="aarch64"
100+ fi
101+ REMOTE_VERSION=$(curl -s "https://plex.tv/downloads/details/5?distro=debian&build=linux-${PLEX_URL_ARCH}&channel=8&X-Plex-Token=$PLEX_TOKEN"| grep -oP 'version="\K[^"]+' | tail -n 1 )
105102elif [[ "${VERSION,,}" = public ]]; then
106- PLEX_TOKEN=""
107- REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
103+ REMOTE_VERSION=curl -sX GET 'https://plex.tv/api/downloads/5.json' | jq -r 'first(.[] | .Linux.version)'
108104else
109105REMOTE_VERSION="${VERSION}"
110106fi
116112
117113echo "Atempting to upgrade to: $REMOTE_VERSION"
118114rm -f /tmp/plexmediaserver_*.deb
119- if [[ $REMOTE_VERSION == 1.15* ]]; then
120115wget -nv -P /tmp \
121- "https://downloads.plex.tv/plex-media-server-new/$REMOTE_VERSION/debian/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
122- else
123- wget -nv -P /tmp \
124- "${PLEX_DOWNLOAD}/$REMOTE_VERSION/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
125- fi
116+ "${PLEX_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb"
126117last=$?
127118
128119# test if deb file size is ok, or if download failed
129- if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64 .deb) -lt 10000 ]]; then
120+ if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_${PLEX_ARCH} .deb) -lt 10000 ]]; then
130121printf '\n\n\n%s\n\n\n' "$(</tmp/update_fail.nfo)"
131122exit 0
132123# if ok, try to install it.
133124else
134- dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64 .deb
125+ dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_${PLEX_ARCH} .deb
135126rm -f /tmp/plexmediaserver_*.deb
136127fi
0 commit comments