mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-14 10:36:55 -07:00
Improve version handling to prevent inadvertent downgrades (#226)
* Improve version handling to prevent inadvertent downgrades * Add verbose output for version checking * Improved git branch handling for testing * Stay on current branch unless BRANCHNAME is set * Add verbose output for in-use check
This commit is contained in:
parent
17cac380b1
commit
293e6d5ecb
2 changed files with 65 additions and 21 deletions
|
@ -228,8 +228,13 @@ if [ "${AUTOUPDATE}" = "yes" ]; then
|
|||
elif ! git diff --quiet; then
|
||||
warn "You have made changes to the plexupdate files, cannot auto update"
|
||||
else
|
||||
if [ -z "${BRANCHNAME}" ]; then
|
||||
BRANCHNAME="$(git symbolic-ref -q --short HEAD)"
|
||||
elif [ "${BRANCHNAME}" != "$(git symbolic-ref -q --short HEAD)" ]; then
|
||||
git checkout "${BRANCHNAME}"
|
||||
fi
|
||||
# Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch)
|
||||
if git fetch origin ${BRANCHNAME:-master} --quiet && ! git diff --quiet FETCH_HEAD; then
|
||||
if git fetch origin ${BRANCHNAME} --quiet && ! git diff --quiet FETCH_HEAD; then
|
||||
info "Auto-updating..."
|
||||
|
||||
# Use an associative array to store permissions. If you're running bash < 4, the declare will fail and we'll
|
||||
|
@ -385,11 +390,7 @@ RELEASE=$(grep -ioe '"label"[^}]*' <<<"${wgetresults}" | grep -i "\"distro\":\"$
|
|||
DOWNLOAD=$(echo ${RELEASE} | grep -m1 -ioe 'https://[^\"]*')
|
||||
CHECKSUM=$(echo ${RELEASE} | grep -ioe '\"checksum\"\:\"[^\"]*' | sed 's/\"checksum\"\:\"//')
|
||||
|
||||
if [ "$VERBOSE" = "yes" ]; then
|
||||
for i in RELEASE DOWNLOAD CHECKSUM; do
|
||||
info "$i=${!i}"
|
||||
done
|
||||
fi
|
||||
verboseOutput RELEASE DOWNLOAD CHECKSUM
|
||||
|
||||
if [ -z "${DOWNLOAD}" ]; then
|
||||
if [ "$DISTRO" = "ubuntu" -a "$BUILD" = "linux-ubuntu-armv7l" ]; then
|
||||
|
@ -423,30 +424,25 @@ fi
|
|||
# By default, try downloading
|
||||
SKIP_DOWNLOAD="no"
|
||||
|
||||
# Installed version detection
|
||||
if [ "${REDHAT}" != "yes" ]; then
|
||||
INSTALLED_VERSION=$(dpkg-query -s plexmediaserver 2>/dev/null | grep -Po 'Version: \K.*')
|
||||
else
|
||||
if [ "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then
|
||||
warn "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
|
||||
fi
|
||||
INSTALLED_VERSION=$(rpm -qv plexmediaserver 2>/dev/null)
|
||||
INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed version, first time?"
|
||||
FILE_VERSION="$(parseVersion "${FILENAME}")"
|
||||
verboseOutput INSTALLED_VERSION FILE_VERSION
|
||||
|
||||
if [ "${REDHAT}" = "yes" -a "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then
|
||||
warn "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
|
||||
fi
|
||||
|
||||
if [ "${CHECKONLY}" = "yes" ]; then
|
||||
if [ -z "${INSTALLED_VERSION}" ]; then
|
||||
warn "Unable to detect installed version, first time?"
|
||||
elif [[ $FILENAME != *$INSTALLED_VERSION* ]]; then
|
||||
AVAIL="$(echo "${FILENAME}" | sed -nr 's/^[^0-9]+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\-[^_]+).*/\1/pg')"
|
||||
info "Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${AVAIL})"
|
||||
if [ -n "${INSTALLED_VERSION}" ] && isNewerVersion "$FILE_VERSION" "$INSTALLED_VERSION"; then
|
||||
info "Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${FILE_VERSION})"
|
||||
exit 7
|
||||
else
|
||||
elif [ -n "${INSTALLED_VERSION}" ]; then
|
||||
info "You are running the latest version of Plex (${INSTALLED_VERSION})"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $FILENAME == *$INSTALLED_VERSION* ]] && [ "${FORCE}" != "yes" ] && [ ! -z "${INSTALLED_VERSION}" ]; then
|
||||
if ! isNewerVersion "$FILE_VERSION" "$INSTALLED_VERSION" && [ "${FORCE}" != "yes" ]; then
|
||||
info "Your OS reports the latest version of Plex ($INSTALLED_VERSION) is already installed. Use -f to force download."
|
||||
exit 0
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue