Last active
February 7, 2022 08:50
-
-
Save marc0der/c5e1e6b8be9d00f57cbb99e92000b948 to your computer and use it in GitHub Desktop.
Preliminary CLI installation of JDK on Mac
This file contains hidden or 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 | |
#Tweak this if need be for you system! | |
TARGET_VOLUME="/Volumes/Macintosh HD" | |
DMG_NAME="jdk-8u101-macosx-x64.dmg" | |
MOUNT_VOLUME="/Volumes/JDK 8 Update 101" | |
SHA_256="680de8ddead3867fc34e7ff380f437c7ddb8dc75eb606186a3e8ae7e3b8c7fbc" | |
echo "Getting the DMG..." | |
curl -L "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/${DMG_NAME}" --cookie oraclelicense=accept-securebackup-cookie > "$DMG_NAME" | |
checksum=$(shasum -a 256 "$DMG_NAME" | awk '{print $1}') | |
if [[ $SHA_256 != $checksum ]]; then | |
echo "SHA-256 does not match!" | |
echo "Expected: $SHA_256" | |
echo "Actual : $checksum" | |
exit 1 | |
else | |
echo "$SHA_256 SHA-256 checksum matches..." | |
fi | |
echo "Attaching to the DMG..." | |
disks=$(hdiutil attach -noverify -nomount "$DMG_NAME") | |
disk=$(echo "$disks" | awk '{print $1;}' | head -n 1) | |
echo "Mounting $disk to /Volumes..." | |
diskutil mountDisk "$disk" | |
echo "We will be needing sudo powers for installing PKG..." | |
sudo -E installer -package "${MOUNT_VOLUME}/JDK 8 Update 101.pkg" -target "${TARGET_VOLUME}" | |
echo "Copying JDK Home to SDKMAN! tmp folder..." | |
cp -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ~/.sdkman/tmp/java-1.8.0u101 | |
echo "Preparing the SDK zip..." | |
cd ~/.sdkman/tmp && zip -qr java-1.8.0u101.zip java-1.8.0u101 | |
echo "Moving SDK zip to archives folder..." | |
mv ~/.sdkman/tmp/java-1.8.0u101.zip ~/.sdkman/archives | |
echo "Moving SDK folder to candidates..." | |
mkdir -p ~/.sdkman/candidates/java/1.8.0u101 | |
mv ~/.sdkman/tmp/java-1.8.0u101/* ~/.sdkman/candidates/java/1.8.0u101 | |
rmdir ~/.sdkman/tmp/java-1.8.0u101 | |
echo "Unmounting volume..." | |
hdiutil unmount "$MOUNT_VOLUME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To see if it works: