CURRENT_VERSION=
UPSTREAM_VERSION=
+DOWNLOAD_URL=
DESCRIPTION=$( cat <<-EOF
Update Micraft server .jar file.
}
+#------------------------------------------------------------------------------
+get_upstream_info() {
+
+ info "Trying to get info about current upstream version."
+
+ local upstream_manifest=$( curl -s "${VERSION_MANIFEST}" )
+ if [[ -z "${upstream_manifest}" ]] ; then
+ error "Did not get a valid manifest from mohjang.com"
+ exit 6
+ fi
+
+ UPSTREAM_VERSION=$( echo "${upstream_manifest}" | jq -r .latest.release )
+ if [[ -z "${UPSTREAM_VERSION}" ]] ; then
+ error "Could not evaluate current version from manifest."
+ exit 7
+ fi
+ info "Latest released version: '${GREEN}${UPSTREAM_VERSION}${NORMAL}'."
+
+ local snapshot=$( echo "${upstream_manifest}" | jq -r .latest.snapshot )
+ if [[ -z "${snapshot}" ]] ; then
+ error "Could not evaluate current snapshot id from manifest."
+ exit 7
+ fi
+ debug "Current snapshot id: '${CYAN}${snapshot}${NORMAL}'."
+
+ DOWNLOAD_URL=$( echo "${upstream_manifest}" | jq -r --arg VERSION_TARGET "${snapshot}" '.versions | .[] | select(.id==$VERSION_TARGET) | .url' - )
+ if [[ -z "${DOWNLOAD_URL=}" ]] ; then
+ error "Could not evaluate download URL of snapshot id '${CYAN}${snapshot}${NORMAL}' from manifest."
+ exit 7
+ fi
+ debug "Download URL: '${CYAN}${DOWNLOAD_URL}${NORMAL}'."
+
+}
+
#------------------------------------------------------------------------------
main() {
check_preferences
detecting_cur_version
+ get_upstream_info
+ if [[ "${UPSTREAM_VERSION}" == "${CURRENT_VERSION}" ]] ; then
+ info "Version '${GREEN}${UPSTREAM_VERSION}${NORMAL}' not changed, no update."
+ exit 0
+ fi
}