Simplify exit codes to only 0-2

This commit is contained in:
Alex Malinovich 2016-12-20 16:41:48 -08:00
commit e14a1a74e3

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."
@ -609,14 +604,14 @@ fi
if ! sha1sum --status -c "${FILE_SHA}"; then if ! sha1sum --status -c "${FILE_SHA}"; 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
@ -661,4 +656,4 @@ if [ "${AUTOSTART}" = "yes" ]; then
fi fi
# If we've made it this far and haven't exited it means an update was downloaded and/or installed # If we've made it this far and haven't exited it means an update was downloaded and/or installed
exit 6 exit 2