Vagrant Tips#2 Oracleのjdkをインストールさせる
のjava8版です。2015年の4月でjdk7のサポートが終了になるとのことなので、そろそろjava8をまじめに勉強しようと思います。
Vagrantfile
Vagrant::Config.run do |config|
config.vm.box = "centos64_6_5"
config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box"
config.vm.provision "shell", path: "setup_jdk.sh"
end
setup_jdk.sh
#!/bin/bash
BASE_DIR="/vagrant"
RPM_DIR="${BASE_DIR}/rpm"
JDK_VERSION=8u73
BUILD_NO=b02
JAVA_RPM_NAME="jdk-${JDK_VERSION}-linux-x64.rpm"
JDK_DOWNLOAD_URL="http://download.oracle.com/otn-pub/java/jdk/${JDK_VERSION}-${BUILD_NO}/${JAVA_RPM_NAME}"
# create dir
if [ ! -d ${RPM_DIR} ]
then
mkdir -p ${RPM_DIR}
else
echo "${RPM_DIR} Is Already Exists So Need Not Create"
fi
# if "rpm for jdk file" is noting
if [ ! -f ${RPM_DIR}/${JAVA_RPM_NAME} ]
then
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JDK_DOWNLOAD_URL} -O /tmp/${JAVA_RPM_NAME}
mv /tmp/${JAVA_RPM_NAME} ${RPM_DIR}/
else
echo "${JAVA_RPM_NAME} Is Already Exists So Need Not Wget"
fi
# install jdk
sudo rpm -ivh ${RPM_DIR}/${JAVA_RPM_NAME}