diff --git a/unix_setup.sh b/unix_setup.sh
index cd29169b4ac2c3488ed65c02428de011aa41a181..bfb4e8ad011f70d73774b1fd5a3a880556ff171d 100644
--- a/unix_setup.sh
+++ b/unix_setup.sh
@@ -35,6 +35,10 @@ echo "---------------------------------------------"
 echo "Checking prerequisites and preparing ${APPLICATION_NAME}:"
 echo "---------------------------------------------"
 
+# make sure cwd is same as script's
+SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
+pushd $SCRIPTPATH
+
 # Verify PhotoRec was installed
 echo -n "Checking for PhotoRec..."
 photorec_filepath=/usr/bin/photorec
@@ -53,7 +57,8 @@ echo -n "Checking for Java..."
 if [ -n "$JAVA_PATH" ]; then 
     if [ -x "$JAVA_PATH/bin/java" ]; then
         # only works on linux; not os x
-        sed -Ei '/^#?\s*jdkhome=.*$' "etc/$APPLICATION_NAME.conf"
+        awk '!/^\s*#?\s*jdkhome=.*$/' etc/$APPLICATION_NAME.conf > etc/$APPLICATION_NAME.conf.tmp && \
+        mv etc/$APPLICATION_NAME.conf.tmp etc/$APPLICATION_NAME.conf && \
         echo "jdkhome=$JAVA_PATH" >> etc/$APPLICATION_NAME.conf
     else
         echo "ERROR: Java was not found in $JAVA_PATH."
@@ -113,6 +118,8 @@ chmod -R u+x autopsy/solr/bin
 # make sure it is executable
 chmod u+x bin/$APPLICATION_NAME
 
+popd
+
 echo
 echo "Application is now configured. You can execute bin/$APPLICATION_NAME to start it"
-echo
+echo
\ No newline at end of file