Skip to content

Commit b1b4525

Browse files
committed
real belt and braches stuff here, trying to cover every possible base though, who cares if the script is a mile long, as long as the user doesn't end up with a borked system
1 parent 892c17b commit b1b4525

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

root/etc/cont-init.d/50-plex-update

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,24 @@ exit 0
9191
fi
9292

9393
echo "Atempting to upgrade to: $REMOTE_VERSION"
94-
last=130
95-
while [[ $last -ne "0" ]]; do
96-
rm -f /tmp/plexmediaserver_*.deb
97-
curl -o /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb -L \
98-
"${PLEX_DOWNLOAD}/$REMOTE_VERSION/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
94+
rm -f /tmp/plexmediaserver_*.deb
95+
wget -nv -P /tmp \
96+
"${PLEX_DOWNLOAD}/$REMOTE_VERSION/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
9997
last=$?
100-
done
10198

102-
# test if deb exists, install it or exit out
103-
if [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb) -gt 10000 ]]; then
104-
apt-get remove --purge -y \
105-
plexmediaserver
106-
dpkg -i /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb
107-
rm -f /tmp/plexmediaserver_*.deb
108-
else
99+
# test if deb file size is ok, or if download failed
100+
if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb) -lt 10000 ]]; then
109101
printf "\n\n\n%s\n\n\n" "$(</tmp/update_fail.nfo)"
110102
exit 0
103+
# if ok, try to install it.
104+
else
105+
dpkg -i /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb || exit 0
106+
rm -f /tmp/plexmediaserver_*.deb
111107
fi
112108

109+
# test if plex is installed and try re-pulling latest if not
110+
dpkg -s plexmediaserver > /dev/null 2>&1 || \
111+
(echo "for some reason the update has failed and plex doesn't seem to be installed, retrying a known version" && curl -o /tmp/plexmediaserver.deb -L "${PLEX_INSTALL}" && dpkg -i /tmp/plexmediaserver.deb)
112+
113113
# recopy config file in case update overwrites our copy
114-
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver
114+
cp /defaults/plexmediaserver /etc/default/plexmediaserver

0 commit comments

Comments
 (0)