Fix RPM version parsing

This commit is contained in:
Alex Malinovich 2018-03-09 00:35:21 -08:00
commit ebd6a5876b
No known key found for this signature in database
GPG key ID: F3327D1AA93CF5F0
2 changed files with 10 additions and 2 deletions

View file

@ -224,13 +224,21 @@ isNewerVersion() {
fi
}
parseVersion() {
if [ "${REDHAT}" = "yes" ]; then
cut -f2- -d- <<< "$1" | cut -f1-4 -d.
else
cut -f2 -d_ <<< "$1"
fi
}
getPlexVersion() {
if [ "${REDHAT}" != "yes" ]; then
dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null
elif hash rpm 2>/dev/null; then
local rpmtemp
if rpmtemp=$(rpm -q plexmediaserver); then
cut -f2 -d_ <<< "$rpmtemp"
parseVersion "$rpmtemp"
else
return 1
fi

View file

@ -420,7 +420,7 @@ fi
SKIP_DOWNLOAD="no"
INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed version, first time?"
FILE_VERSION="$(cut -f2 -d_ <<< "${FILENAME}")"
FILE_VERSION="$(parseVersion "${FILENAME}")"
verboseOutput INSTALLED_VERSION FILE_VERSION
if [ "${REDHAT}" = "yes" -a "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then