Update adoptium-get-jdk-link.sh
script content
#812
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update `adoptium-get-jdk-link.sh` script content
Update script content
1 file(s) updated with "#!/bin/sh\n\n# Check if at least one argument was passed to the script\n# If one argument was passed and JAVA_VERSION is set, assign the argument to OS\n# If two arguments were passed, assign them to JAVA_VERSION and OS respectively\n# If three arguments were passed, assign them to JAVA_VERSION, OS and ARCHS respectively\n# If not, check if JAVA_VERSION and OS are already set. If they're not set, exit the script with an error message\nif [$# -eq 1 ] && [ -n \"$ {JAVA_VERSION}\" ]; then\n OS=\"${1}\"\nelif [ $# -eq 2 ]; then\n JAVA_VERSION=\"$ {1}\"\n OS=\"${2}\"\nelif [ $# -eq 3 ]; then\n JAVA_VERSION=\"$ {1}\"\n OS=\"${2}\"\n ARCHS=$3\nelif [ -z \"${JAVA_VERSION}\" ] && [ -z \"${OS}\" ]; then\n echo \"Error: No Java version and OS specified. Please set the JAVA_VERSION and OS environment variables or pass them as arguments.\" >&2\n exit 1\nelif [ -z \"${JAVA_VERSION}\" ]; then\n echo \"Error: No Java version specified. Please set the JAVA_VERSION environment variable or pass it as an argument.\" >&2\n exit 1\nelif [ -z \"${OS}\" ]; then\n OS=\"${1}\"\n if [ -z \"${OS}\" ]; then\n echo \"Error: No OS specified. Please set the OS environment variable or pass it as an argument.\" >&2\n exit 1\n fi\nfi\n\n# Check if ARCHS is set. If it's not set, assign the current architecture to it\nif [ -z \"${ARCHS}\" ]; then\n ARCHS=$(uname -m | sed -e 's/x86_64/x64/' -e 's/armv7l/arm/')\nelse\n # Convert ARCHS to an array\n OLD_IFS=\"${IFS}\"\n IFS=','\n set -- \"${ARCHS}\"\n ARCHS=\"\"\n for arch in \"$@\"; do\n ARCHS=\"${ARCHS} ${arch}\"\n done\n IFS=\"${OLD_IFS}\"\nfi\n\n# Check if jq and curl are installed\n# If they are not installed, exit the script with an error message\nif ! command -v jq >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then\n echo \"jq and curl are required but not installed. Exiting with status 1.\" >&2\n exit 1\nfi\n\n# Replace underscores with plus signs in JAVA_VERSION\nARCHIVE_DIRECTORY=$(echo \"${JAVA_VERSION}\" | tr '_' '+')\n\n# URL encode ARCHIVE_DIRECTORY\nENCODED_ARCHIVE_DIRECTORY=$(echo \"${ARCHIVE_DIRECTORY}\" | xargs -I {} printf %s {} | jq \"@uri\" -jRr)\n\n# Determine the OS type for the URL\nOS_TYPE=\"linux\"\nif [ \"${OS}\" = \"alpine\" ]; then\n OS_TYPE=\"alpine-linux\"\nfi\nif [ \"${OS}\" = \"windows\" ]; then\n OS_TYPE=\"windows\"\nfi\n\n# Initialize a variable to store the URL for the first architecture\nFIRST_ARCH_URL=\"\"\n\n# Loop over the array of architectures\nfor ARCH in ${ARCHS}; do\n # Fetch the download URL from the Adoptium API\n URL=\"https://api.adoptium.net/v3/binary/version/jdk-${ENCODED_ARCHIVE_DIRECTORY}/${OS_TYPE}/${ARCH}/jdk/hotspot/normal/eclipse?project=jdk\"\n\n if ! RESPONSE=$(curl -fsI \"${URL}\"); then\n echo \"Error: Failed to fetch the URL for architecture ${ARCH}. Exiting with status 1.\" >&2\n echo \"Response: ${RESPONSE}\" >&2\n exit 1\n fi\n\n # Extract the redirect URL from the HTTP response\n REDIRECTED_URL=$(echo \"${RESPONSE}\" | grep Location | awk '{print $2}' | tr -d '\\r')\n\n # If no redirect URL was found, exit the script with an error message\n if [ -z \"$ {REDIRECTED_URL}\" ]; then\n echo \"Error: No redirect URL found for architecture ${ARCH}. Exiting with status 1.\" >&2\n echo \"Response: ${RESPONSE}\" >&2\n exit 1\n fi\n\n # Use curl to check if the URL is reachable\n # If the URL is not reachable, print an error message and exit the script with status 1\n if ! curl -v -fs \"${REDIRECTED_URL}\" >/dev/null 2>&1; then\n echo \"${REDIRECTED_URL}\" is not reachable for architecture \"${ARCH}\". >&2\n exit 1\n fi\n\n # If FIRST_ARCH_URL is empty, store the current URL\n if [ -z \"${FIRST_ARCH_URL}\" ]; then\n FIRST_ARCH_URL=${REDIRECTED_URL}\n fi\ndone\n\n# If all downloads are successful, print the URL for the first architecture\necho \"${FIRST_ARCH_URL}\"\n":
* adoptium-get-jdk-link.sh
Created automatically by Updatecli
Options:
Most of Updatecli configuration is done via its manifest(s).
Feel free to report any issues at github.com/updatecli/updatecli.
If you find this tool useful, do not hesitate to star our GitHub repository as a sign of appreciation, and/or to tell us directly on our chat!