allows setup for autopsy extracted directory

This commit is contained in:
Greg DiCristofaro 2022-09-12 15:48:39 -04:00
parent 396c838623
commit 238c75a100

View File

@ -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,17 +64,20 @@ 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
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..."