-
-
Save keir-nellyer/7ff0c44fd2eecc4c2cf3 to your computer and use it in GitHub Desktop.
get_jdk_linux_x64.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: get_jdk.sh <jdk_version> <rpm|tar> | |
# jdk_version: default 8 | |
# rpm | |
JDK_VERSION="8" | |
EXT="rpm" | |
if [ -n "$1" ]; then | |
if [ "$1" == "7" ]; then | |
JDK_VERSION="7" | |
fi | |
fi | |
if [ -n "$2" ]; then | |
if [ "$2" == "tar" ]; then | |
EXT="tar.gz" | |
fi | |
fi | |
URL="http://www.oracle.com" | |
JDK_DOWNLOAD_URL1="${URL}/technetwork/java/javase/downloads/index.html" | |
JDK_DOWNLOAD_URL2=`curl -s $JDK_DOWNLOAD_URL1 | egrep -o "\/technetwork\/java/\javase\/downloads\/jdk${JDK_VERSION}-downloads-.*\.html" | head -1` | |
if [ -z "$JDK_DOWNLOAD_URL2" ]; then | |
echo "Could not get jdk download url - $JDK_DOWNLOAD_URL1" | |
exit 1 | |
fi | |
JDK_DOWNLOAD_URL3="${URL}${JDK_DOWNLOAD_URL2}" | |
JDK_DOWNLOAD_URL4=`curl -s $JDK_DOWNLOAD_URL3 | egrep -o "http\:\/\/download.oracle\.com\/otn-pub\/java\/jdk\/[7-8]u[0-9]+\-(.*)+\/jdk-[7-8]u[0-9]+(.*)linux-x64.${EXT}"` | |
wget --no-cookies \ | |
--no-check-certificate \ | |
--header "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
$JDK_DOWNLOAD_URL4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment