This commit is contained in:
Alex Malinovich 2016-12-21 00:50:14 +00:00 committed by GitHub
commit 6e465da0e1

View file

@ -21,10 +21,8 @@
# #
# Returns 0 on success # Returns 0 on success
# 1 on error # 1 on error
# 2 if file already downloaded # 2 an update was found/installed
# 3 if page layout has changed. # 255 an invalid parameter/combination was passed to plexupdate
# 4 if download fails
# 6 if update was deferred due to usage
# #
# All other return values not documented. # All other return values not documented.
# #
@ -531,13 +529,13 @@ CHECKSUM=$(echo ${RELEASE} | grep -ioe '\"checksum\"\:\"[^\"]*' | sed 's/\"check
if [ -z "${DOWNLOAD}" ]; then if [ -z "${DOWNLOAD}" ]; then
error "Unable to retrieve the URL needed for download (Query DISTRO: $DISTRO, BUILD: $BUILD)" error "Unable to retrieve the URL needed for download (Query DISTRO: $DISTRO, BUILD: $BUILD)"
exit 3 exit 1
fi fi
FILENAME="$(basename 2>/dev/null ${DOWNLOAD})" FILENAME="$(basename 2>/dev/null ${DOWNLOAD})"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
error "Failed to parse HTML, download cancelled." error "Failed to parse HTML, download cancelled."
exit 3 exit 1
fi fi
echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"${FILE_SHA}" echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >"${FILE_SHA}"
@ -570,9 +568,6 @@ if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then
sha1sum --status -c "${FILE_SHA}" sha1sum --status -c "${FILE_SHA}"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
info "File already exists (${FILENAME}), won't download." info "File already exists (${FILENAME}), won't download."
if [ "${AUTOINSTALL}" != "yes" ]; then
exit 2
fi
SKIP_DOWNLOAD="yes" SKIP_DOWNLOAD="yes"
else else
info "File exists but fails checksum. Redownloading." info "File exists but fails checksum. Redownloading."
@ -607,17 +602,16 @@ if [ "${SKIP_DOWNLOAD}" = "no" ]; then
info "File downloaded" info "File downloaded"
fi fi
sha1sum --status -c "${FILE_SHA}" if ! sha1sum --status -c "${FILE_SHA}"; then
if [ $? -ne 0 ]; then
error "Downloaded file corrupt. Try again." error "Downloaded file corrupt. Try again."
exit 4 exit 1
fi fi
if [ ! -z "${PLEXSERVER}" -a "${AUTOINSTALL}" = "yes" ]; then if [ ! -z "${PLEXSERVER}" -a "${AUTOINSTALL}" = "yes" ]; then
# Check if server is in-use before continuing (thanks @AltonV, @hakong and @sufr3ak)... # Check if server is in-use before continuing (thanks @AltonV, @hakong and @sufr3ak)...
if running ${PLEXSERVER} ${TOKEN} ${PLEXPORT}; then if running ${PLEXSERVER} ${TOKEN} ${PLEXPORT}; then
error "Server ${PLEXSERVER} is currently being used by one or more users, skipping installation. Please run again later" error "Server ${PLEXSERVER} is currently being used by one or more users, skipping installation. Please run again later"
exit 6 exit 2
fi fi
fi fi
@ -628,6 +622,11 @@ if [ "${AUTOINSTALL}" = "yes" ]; then
# no elif since DISTRO_INSTALL will produce error output for us # no elif since DISTRO_INSTALL will produce error output for us
${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}" ${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"
RET=$?
if [ $RET -ne 0 ]; then
error "Error reported while installing ${FILENAME}."
exit $RET
fi
fi fi
if [ "${AUTODELETE}" = "yes" ]; then if [ "${AUTODELETE}" = "yes" ]; then
@ -656,4 +655,5 @@ if [ "${AUTOSTART}" = "yes" ]; then
fi fi
fi fi
exit 0 # If we've made it this far and haven't exited it means an update was downloaded and/or installed
exit 2