-
-
Save bionix/7a5f4601ef0535dd8e24a398fef944a1 to your computer and use it in GitHub Desktop.
Get latest Oracle JDK package bash shell script
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 | |
# You must accept the Oracle Binary Code License | |
# http://www.oracle.com/technetwork/java/javase/terms/license/index.html | |
# usage: get_jdk.sh <ext> <jdk_version> | |
# ext: rpm | |
# jdk_version: default 8 | |
ext=rpm | |
jdk_version=8 | |
if [ -n "$1" ]; then | |
if [ "$1" == "tar" ]; then | |
ext="tar.gz" | |
fi | |
fi | |
readonly url="http://www.oracle.com" | |
readonly jdk_download_url1="$url/technetwork/java/javase/downloads/index.html" | |
readonly jdk_download_url2=$(curl -s $jdk_download_url1 | egrep -o "\/technetwork\/java/\javase\/downloads\/jdk${jdk_version}-downloads-.+?\.html" | head -1 | cut -d '"' -f 1) | |
[[ -z "$jdk_download_url2" ]] && error "Could not get jdk download url - $jdk_download_url1" | |
readonly jdk_download_url3="${url}${jdk_download_url2}" | |
readonly 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") | |
for dl_url in ${jdk_download_url4[@]}; do | |
wget --no-cookies \ | |
--no-check-certificate \ | |
--header "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
-N $dl_url | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment