#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm
sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork
#Extract the download
tar -zxvf $downloadDir/jdk*tar.gz
#Move it to where it can be found...
sudo mv -f $tempWork/jdk* $javaUsrLib/
sudo ln -f -s $javaUsrLib/jdk1/bin/* /usr/bin/
#Update this line to reflect versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
#Extract the download
tar -zxvf $tempWork/*
#Move it to where it can be found...
sudo mv -f $tempWork/jdk1* $javaUsrLib/
sudo ln -f -s $javaUsrLib/jdk1*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_03" /etc/environment
then
echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_03"| sudo tee -a /etc/environment
fi
exit 0
ME=<myOracleID>
PW=<myOraclePW>
PATCH_FILE=p13079846_17000_Linux-x86-64.zip
echo "Get real URL from the persistent link"
wget -o getrealurl.out --no-cookies --no-check-certificate --user=$ME \
--password=$PW --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \
https://updates.oracle.com/Orion/Services/download/$PATCH_FILE?aru=16884382&\
patch_file=$PATCH_FILE
wait # wget appears to go into background, so "wait" waits
# until all background processes complete
REALURL=`grep "^--" getrealurl.out |tail -1 |sed -e 's/.*http/http/'`
wget -O $PATCH_FILE $REALURL
#These last steps must be done quickly, as the REALURL seems to have a short-lived
#cookie on it and I've had no success with --keep-session-cookies etc.
jdk-download< <version> <platform> [<build>]
* <version> - Something like "8u40"
* <platform> - Usually i586 or x64
* <build> - The internal build number used by oracle, to avoid guessing and trying to download starting from 99 to 1 (build 0, really?!!)
< a href = " http://bonfab.io/?p=10" rel="nofollow">博客文章
3)在pnda-static-file-dependencies.txt的第一行是一个从http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz oraclelicense=accept-securebackup-cookie下载jdk-8u131-linux-x64.tar.gz文件的引用;在这一点上,我的脚本失败的消息Failed to download http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz after 3 retries
4)我浏览到http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz页面,发现以下错误消息显示为**In order to download products from Oracle Technology Network you must agree to the OTN license terms**
#!/bin/bash
### Proxy settings
# If there is a company proxy
PROXY="my.proxy.local:8080"
PROXY_TYPE="--proxy-ntlm" # or leave empty with ""
USER="user"
PASS='pass'
### Find out the links to JRE and JDK
# To do so, got to the page http://www.oracle.com/technetwork/java/javase/downloads/
BASE_URL="technetwork/java/javase/downloads"
# Put the whole page into a single string/line
BASE_URL_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}@${PROXY}" -L0 http://www.oracle.com/${BASE_URL}/)"
# Define the environments to download
JAVA_ENVIRONMENTS=("JRE" "JDK") # ! yet "SERVER-JRE"
for JAVA_ENVIRONMENT in "${JAVA_ENVIRONMENTS[@]}"
do
echo
echo "JAVA_ENVIRONMENT="$JAVA_ENVIRONMENT
echo
for (( JAVA_BASE_VERSION = 8; JAVA_BASE_VERSION <= 10; JAVA_BASE_VERSION += 2 ))
do
echo "JAVA_BASE_VERSION="$JAVA_BASE_VERSION
### "Read the page"
# and follow the links for the package interested in
DOWNLOAD_SITE="$(echo $BASE_URL_OUTPUT | grep -m 1 -io "${JAVA_ENVIRONMENT}${JAVA_BASE_VERSION}-downloads-[0-9]*.html" -- | tail -1)"
echo "DOWNLOAD_SITE="$DOWNLOAD_SITE
### Gather the necessary download links
# To do so, following the link to the download site
# reading and accept the license
#
# ... the greedy regular expression is to address the different syntax of the links
# and already prepared for OR .gz files
DOWNLOAD_LINK_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}@${PROXY}" -L -j -H "Cookie: oraclelicense=accept-securebackup-cookie" http://www.oracle.com/${BASE_URL}/${DOWNLOAD_SITE} | grep -io "filepath.*${JAVA_ENVIRONMENT}-[${JAVA_BASE_VERSION}].*linux[-_]x64[._].*\(rpm\)" -- | cut -d '"' -f 3 | tail -1)"
# and echo out the link
echo "DOWNLOAD_LINK_OUTPUT="$DOWNLOAD_LINK_OUTPUT
done
done