@@ -228,8 +228,13 @@ if [ "${AUTOUPDATE}" = "yes" ]; then
228228 elif ! git diff --quiet; then
229229 warn " You have made changes to the plexupdate files, cannot auto update"
230230 else
231+ if [ -z " ${BRANCHNAME} " ]; then
232+ BRANCHNAME=" $( git symbolic-ref -q --short HEAD) "
233+ elif [ " ${BRANCHNAME} " != " $( git symbolic-ref -q --short HEAD) " ]; then
234+ git checkout " ${BRANCHNAME} "
235+ fi
231236 # Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch)
232- if git fetch origin ${BRANCHNAME:- master } --quiet && ! git diff --quiet FETCH_HEAD; then
237+ if git fetch origin ${BRANCHNAME} --quiet && ! git diff --quiet FETCH_HEAD; then
233238 info " Auto-updating..."
234239
235240 # 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\":\"$
385390DOWNLOAD=$( echo ${RELEASE} | grep -m1 -ioe ' https://[^\"]*' )
386391CHECKSUM=$( echo ${RELEASE} | grep -ioe ' \"checksum\"\:\"[^\"]*' | sed ' s/\"checksum\"\:\"//' )
387392
388- if [ " $VERBOSE " = " yes" ]; then
389- for i in RELEASE DOWNLOAD CHECKSUM; do
390- info " $i =${! i} "
391- done
392- fi
393+ verboseOutput RELEASE DOWNLOAD CHECKSUM
393394
394395if [ -z " ${DOWNLOAD} " ]; then
395396 if [ " $DISTRO " = " ubuntu" -a " $BUILD " = " linux-ubuntu-armv7l" ]; then
423424# By default, try downloading
424425SKIP_DOWNLOAD=" no"
425426
426- # Installed version detection
427- if [ " ${REDHAT} " != " yes" ]; then
428- INSTALLED_VERSION=$( dpkg-query -s plexmediaserver 2> /dev/null | grep -Po ' Version: \K.*' )
429- else
430- if [ " ${AUTOINSTALL} " = " yes" -a " ${AUTOSTART} " = " no" ]; then
431- warn " Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
432- fi
433- INSTALLED_VERSION=$( rpm -qv plexmediaserver 2> /dev/null)
427+ INSTALLED_VERSION=" $( getPlexVersion) " || warn " Unable to detect installed version, first time?"
428+ FILE_VERSION=" $( parseVersion " ${FILENAME} " ) "
429+ verboseOutput INSTALLED_VERSION FILE_VERSION
430+
431+ if [ " ${REDHAT} " = " yes" -a " ${AUTOINSTALL} " = " yes" -a " ${AUTOSTART} " = " no" ]; then
432+ warn " Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
434433fi
435434
436435if [ " ${CHECKONLY} " = " yes" ]; then
437- if [ -z " ${INSTALLED_VERSION} " ]; then
438- warn " Unable to detect installed version, first time?"
439- elif [[ $FILENAME != * $INSTALLED_VERSION * ]]; then
440- AVAIL=" $( echo " ${FILENAME} " | sed -nr ' s/^[^0-9]+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\-[^_]+).*/\1/pg' ) "
441- info " Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${AVAIL} )"
436+ if [ -n " ${INSTALLED_VERSION} " ] && isNewerVersion " $FILE_VERSION " " $INSTALLED_VERSION " ; then
437+ info " Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${FILE_VERSION} )"
442438 exit 7
443- else
439+ elif [ -n " ${INSTALLED_VERSION} " ] ; then
444440 info " You are running the latest version of Plex (${INSTALLED_VERSION} )"
445441 fi
446442 exit 0
447443fi
448444
449- if [[ $FILENAME == * $INSTALLED_VERSION * ]] && [ " ${FORCE} " != " yes" ] && [ ! -z " ${INSTALLED_VERSION} " ]; then
445+ if ! isNewerVersion " $FILE_VERSION " " $INSTALLED_VERSION " && [ " ${FORCE} " != " yes" ]; then
450446 info " Your OS reports the latest version of Plex ($INSTALLED_VERSION ) is already installed. Use -f to force download."
451447 exit 0
452448fi
0 commit comments