Skip to content

Instantly share code, notes, and snippets.

@mapio
Last active March 27, 2018 06:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mapio/1283092dfdbe5dfb26c7 to your computer and use it in GitHub Desktop.
Save mapio/1283092dfdbe5dfb26c7 to your computer and use it in GitHub Desktop.
A couple of scripts for unattended install of Oracle JDK 8 on Ubuntu and OS X
#!/bin/bash
echocol() { echo -e "\033[32m*** $@...\033[0m"; }
echocol "Attempting to download the JDK installer disk image"
attempts=5
while ! curl -H "Cookie: oraclelicense=accept-securebackup-cookie" -C - -#LO http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-macosx-x64.dmg; do
if [[ $attempts == 0 ]]; then break; fi
echo "[restarting an interruped download]"
sleep 1;
attempts=$(( $attempts - 1 ))
done
echocol "Verifying the JDK installer disk image"
if ! hdiutil verify jdk-8u101-macosx-x64.dmg >/dev/null 2>&1; then
echo "The downloaded image is corrupted!"
exit 1
fi
echocol "Attaching the JDK installer disk image"
if ! hdiutil attach jdk-8u101-macosx-x64.dmg >/dev/null 2>&1; then
echo "Failed to attach the image"
exit 1
fi
echocol "Installing the JDK package (please type your password first)"
sudo installer -pkg /Volumes/JDK\ 8\ Update\ 101/JDK\ 8\ Update\ 101.pkg -target /
echocol "Ejecting the JDK installer volume"
hdiutil eject /Volumes/JDK\ 8\ Update\ 101/ 2>&1
echo "If you want to remove the JDK installer disk image type 'rm jdk-8u101-macosx-x64.dmg'..."
#!/bin/bash
echocol() { echo -e "\033[32m*** $@...\033[0m"; }
echocol "Updating the package list"
sudo apt-get update -q
echocol "Adding and configuring the JDK repository"
export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -q -y software-properties-common </dev/null
sudo bash -c 'echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections'
sudo bash -c 'echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections'
sudo add-apt-repository ppa:webupd8team/java
echocol "Updating the package list after adding the JDK repo"
sudo apt-get update -q
echocol "Installing the JDK"
sudo apt-get install -q -y oracle-java8-installer
@mapio
Copy link
Author

mapio commented Oct 9, 2015

You can use this scripts as:

  • curl -sL http://git.io/vCY53 | bash on OS X, and
  • curl -sL http://git.io/vCY58 | bash on Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment