From 800ce196a805f4d6ed59bb76e100bae520f98177 Mon Sep 17 00:00:00 2001
From: Greg DiCristofaro <gregd@basistech.com>
Date: Mon, 27 Sep 2021 12:11:31 -0400
Subject: [PATCH] beginning of unix setup changes

---
 unix_setup.sh | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/unix_setup.sh b/unix_setup.sh
index 6554689384..68de74fb86 100644
--- a/unix_setup.sh
+++ b/unix_setup.sh
@@ -8,6 +8,30 @@
 TSK_VERSION=4.11.0
 
 
+usage() { 
+    echo "Usage: unix_setup.sh [-j java_home]" 1>&2;
+}
+
+while getopts "j:" o; do
+    case "${o}" in
+        j)
+            JAVA_PATH=${OPTARG}
+            ;;
+        *)
+            usage
+            exit 1
+            ;;
+    esac
+done
+
+
+
+if [[ -z "${SLEUTHKIT_SRC_DIR}" ]] || [[ -z "${TSK_BRANCH}" ]]; then
+    usage
+    exit 1
+fi
+
+
 # In the beginning...
 echo "---------------------------------------------"
 echo "Checking prerequisites and preparing Autopsy:"
@@ -28,12 +52,19 @@ fi
 
 # Verify Java was installed and configured
 echo -n "Checking for Java..."
-if [ -n "$JAVA_HOME" ];  then
+if [ -n "$JAVA_PATH"]; then 
+    if [ -x "$JAVA_PATH/bin/java" ]; then
+        # TODO
+    else
+        echo "ERROR: Java was not found in $JAVA_PATH."
+        exit 1
+    fi
+elif [ -n "$JAVA_HOME" ];  then
     if [ -x "$JAVA_HOME/bin/java" ]; then
-	echo "found in $JAVA_HOME"
+	    echo "found in $JAVA_HOME"
     else
-	echo "ERROR: Java was not found in $JAVA_HOME."
-	exit 1
+        echo "ERROR: Java was not found in $JAVA_HOME."
+        exit 1
     fi
 else
     echo "ERROR: JAVA_HOME environment variable must be defined."
-- 
GitLab