autopsy-flatpak/installation/scripts/install_prereqs_osx.sh
2021-04-22 13:23:47 -04:00

68 lines
2.0 KiB
Bash

#!/bin/bash
# for macOS BigSur and later:
# based on https://www.cyberciti.biz/faq/mac-osx-find-tell-operating-system-version-from-bash-prompt/
# and https://superuser.com/questions/1425135/parsing-macos-plist-values
OSX_VERSION_STR=$(defaults read /System/Library/CoreServices/SystemVersion ProductVersion)
if [[[ $OSX_VERSION_STR =~ "([\\d*]])\\.([\\d*])\\.([\\d*])" ]]
then
OSX_MAJOR_VERSION=BASH_REMATCH[1]
OSX_MINOR_VERSION=BASH_REMATCH[2]
OSX_PATCH_VERSION=BASH_REMATCH[3]
else
echo "Unable to determine OS X version!" >> /dev/stderr
exit 1
fi
echo "Installing dependencies..."
# dependencies taken from: https://github.com/sleuthkit/autopsy/pull/5111/files
# brew install postgresql gettext cppunit && \
brew install ant automake libtool afflib libewf libpq testdisk imagemagick gstreamer gst-plugins-base gst-plugins-good imagemagick && \
brew tap bell-sw/liberica
if [[ $? -ne 0 ]]
then
echo "Unable to install necessary dependencies" >> /dev/stderr
exit 1
fi
# if BigSur or greater
echo "Installing liberica java 8..."
if ((OSX_MAJOR_VERSION > 11 || (OSX_MAJOR_VERSION == 11 && OSX_MAJOR_VERSION >= 2)))
then
brew install --cask liberica-jdk8-full
else
brew cask install liberica-jdk8-full
fi
if [[ $? -ne 0 ]]
then
echo "Unable to install liberica java" >> /dev/stderr
exit 1
fi
# put this in bash_rc
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) && \
echo "Java home is now: $JAVA_HOME" && \
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' | tee >> ~/.bashrc >> ~/.zshrc
if [[ $? -ne 0 ]]
then
echo "Unable to properly set up JAVA_HOME." >> /dev/stderr
exit 1
fi
OPEN_JDK_LN=/usr/local/opt/openjdk && \
rm $ && \
ln -s $JAVA_HOME $OPEN_JDK_LN
if [[ $? -ne 0 ]]
then
echo "Unable to properly set up $OPEN_JDK_LN." >> /dev/stderr
exit 1
fi
# Test your link file creation to ensure it is pointing at the correct java developement kit:
echo "/usr/local/opt/openjdk now is:"
ls -l /usr/local/opt/openjdk
# check version
echo "Java Version is:"
java -version