autopsy icon indicating copy to clipboard operation
autopsy copied to clipboard

add_macos_jna.sh

Open NEW-BOOTY opened this issue 8 months ago • 1 comments

#!/bin/bash

Copyright © 2025 Devin B. Royal.

All Rights Reserved.

This script adds the macOS-specific JNA (Java Native Access) library path to the Autopsy configuration.

set -e # Exit immediately if a command exits with a non-zero status. set -u # Treat unset variables as errors. set -o pipefail # Catch errors in pipelines.

LOG_FILE="add_macos_jna.log"

Logging function

log_message() { echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE" }

Validate script execution

log_message "Starting add_macos_jna.sh script."

Define the JNA library path for macOS

JNA_LIB_PATH="/usr/local/lib/jna"

Check if JNA library path exists

if [ ! -d "$JNA_LIB_PATH" ]; then log_message "JNA library path not found: $JNA_LIB_PATH" log_message "Please install JNA for macOS using Homebrew: brew install jna" exit 1 fi

Locate Autopsy's configuration file

AUTOPSY_CONF_DIR="${HOME}/autopsy-4.21.0" AUTOPSY_CONF_FILE="${AUTOPSY_CONF_DIR}/etc/autopsy.conf"

if [ ! -f "$AUTOPSY_CONF_FILE" ]; then log_message "Autopsy configuration file not found: $AUTOPSY_CONF_FILE" log_message "Ensure that Autopsy is correctly installed and configured." exit 1 fi

Backup the existing configuration file

BACKUP_CONF_FILE="${AUTOPSY_CONF_FILE}.bak.$(date '+%Y%m%d%H%M%S')" cp "$AUTOPSY_CONF_FILE" "$BACKUP_CONF_FILE" log_message "Backup created for the configuration file: $BACKUP_CONF_FILE"

Add the JNA library path to the configuration file

if grep -q "jna.library.path" "$AUTOPSY_CONF_FILE"; then sed -i '' "s|jna.library.path=.*|jna.library.path=${JNA_LIB_PATH}|" "$AUTOPSY_CONF_FILE" log_message "Updated JNA library path in the configuration file." else echo "jna.library.path=${JNA_LIB_PATH}" >> "$AUTOPSY_CONF_FILE" log_message "Added JNA library path to the configuration file." fi

log_message "JNA library path successfully configured for Autopsy." log_message "Script execution completed successfully." exit 0

NEW-BOOTY avatar Jan 29 '25 14:01 NEW-BOOTY