#!/bin/bash
BINARY_NAME="nosql"
TARGET_DIR="$HOME/.local/bin"
BINARY_PATH="$TARGET_DIR/$BINARY_NAME"
DOWNLOAD_URL="https://s3.nosqlbooster.com/download/releasesv7/nosqlbooster4mongo-7.1.17.AppImage"

if [ ! -x "$BINARY_PATH" ]; then
	notify-send "📦 Installing $BINARY_NAME" "Downloading NoSQL Booster..."

	mkdir -p "$TARGET_DIR"

	wget -q -O "$BINARY_PATH" "$DOWNLOAD_URL" || {
		notify-send -u critical "Installation Failed" "Failed to download $BINARY_NAME"
		exit 1
	}

	chmod +x "$BINARY_PATH"

	notify-send "Installation Complete" "$BINARY_NAME has been installed successfully"
fi

exec "$BINARY_PATH" "$@"
