From 238c75a100b12f560e07465808ca6d60556c1605 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Mon, 12 Sep 2022 15:48:39 -0400 Subject: [PATCH] allows setup for autopsy extracted directory --- .../install_application_from_zip.sh | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/linux_macos_install_scripts/install_application_from_zip.sh b/linux_macos_install_scripts/install_application_from_zip.sh index 4963ac9da0..fdc67f1572 100644 --- a/linux_macos_install_scripts/install_application_from_zip.sh +++ b/linux_macos_install_scripts/install_application_from_zip.sh @@ -3,7 +3,7 @@ usage() { echo "Usage: install_application_from_zip.sh [-z zip_path] [-i install_directory] [-j java_home] [-n application_name] [-v asc_file]" 1>&2 - echo "If specifying a .asc verification file (with -v flag), the program will attempt to create a temp folder in the working directory and verify the signature with gpg." 1>&2 + echo "If specifying a .asc verification file (with -v flag), the program will attempt to create a temp folder in the working directory and verify the signature with gpg. If you already have an extracted zip, the '-z' flag can be ignored as long as the directory specifying the extracted contents is provided for the installation directory." 1>&2 } APPLICATION_NAME="autopsy"; @@ -32,12 +32,19 @@ while getopts "n:z:i:j:v:" o; do esac done -if [[ -z "$APPLICATION_ZIP_PATH" ]] || [[ -z "$INSTALL_DIR" ]]; then +if [[ -z "$INSTALL_DIR" ]]; then usage exit 1 fi -if [[ -n "$ASC_FILE" ]]; then +# If zip path has not been specified and there is nothing at the install directory +if [[ -z "$APPLICATION_ZIP_PATH" ]] && [[ ! -d "$INSTALL_DIR" ]]; then + usage + exit 1 +fi + +# check against the asc file if the zip exists +if [[ -n "$ASC_FILE" ]] && [[ -n "$APPLCATION_ZIP_PATH" ]]; then VERIFY_DIR=$(pwd)/temp KEY_DIR=$VERIFY_DIR/private mkdir -p $VERIFY_DIR && @@ -57,18 +64,21 @@ ZIP_FILE_NAME=$(basename -- "$APPLICATION_ZIP_PATH") ZIP_NAME="${ZIP_FILE_NAME%.*}" APPLICATION_EXTRACTED_PATH=$INSTALL_DIR/$ZIP_NAME/ -if [[ -d $APPLICATION_EXTRACTED_PATH || -f $APPLICATION_EXTRACTED_PATH ]]; then - echo "A file or directory already exists at $APPLICATION_EXTRACTED_PATH" >>/dev/stderr - exit 1 -fi +# if specifying a zip path, ensure directory doesn't exist and then create and extract +if [[ -n "$APPLCATION_ZIP_PATH" ]]; then + if [[ -d $APPLICATION_EXTRACTED_PATH || -f $APPLICATION_EXTRACTED_PATH ]]; then + echo "A file or directory already exists at $APPLICATION_EXTRACTED_PATH" >>/dev/stderr + exit 1 + fi -echo "Extracting $APPLICATION_ZIP_PATH to $APPLICATION_EXTRACTED_PATH..." -mkdir -p $APPLICATION_EXTRACTED_PATH && - unzip $APPLICATION_ZIP_PATH -d $INSTALL_DIR -if [[ $? -ne 0 ]]; then - echo "Unable to successfully extract $APPLICATION_ZIP_PATH to $INSTALL_DIR" >>/dev/stderr - exit 1 -fi + echo "Extracting $APPLICATION_ZIP_PATH to $APPLICATION_EXTRACTED_PATH..." + mkdir -p $APPLICATION_EXTRACTED_PATH && + unzip $APPLICATION_ZIP_PATH -d $INSTALL_DIR + if [[ $? -ne 0 ]]; then + echo "Unable to successfully extract $APPLICATION_ZIP_PATH to $INSTALL_DIR" >>/dev/stderr + exit 1 + fi +fi echo "Setting up application at $APPLICATION_EXTRACTED_PATH..." pushd $APPLICATION_EXTRACTED_PATH &&