#!/usr/bin/env python3 """ Setup script for Sherlock OSINT Tool """ import subprocess import sys from pathlib import Path def run_command(command: str, description: str) -> bool: """Run a command and return success status.""" print(f"šŸ”„ {description}...") try: result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) print(f"āœ… {description} completed successfully") return True except subprocess.CalledProcessError as e: print(f"āŒ {description} failed: {e}") if e.stdout: print(f"STDOUT: {e.stdout}") if e.stderr: print(f"STDERR: {e.stderr}") return False def check_uv_installed() -> bool: """Check if UV is installed.""" try: result = subprocess.run(["uv", "--version"], capture_output=True, text=True) print(f"āœ… UV is installed: {result.stdout.strip()}") return True except FileNotFoundError: print("āŒ UV is not installed") return False def install_uv() -> bool: """Install UV package manager.""" print("šŸ”„ Installing UV package manager...") try: # Try to install UV install_cmd = "curl -LsSf https://astral.sh/uv/install.sh | sh" result = subprocess.run(install_cmd, shell=True, check=True) print("āœ… UV installed successfully") return True except subprocess.CalledProcessError: print("āŒ Failed to install UV automatically") print("Please install UV manually: https://astral.sh/uv/") return False def setup_environment() -> bool: """Set up the Python environment.""" print("\nšŸš€ Setting up Sherlock OSINT Tool environment...") # Check if UV is installed if not check_uv_installed(): if not install_uv(): return False # Create virtual environment and install dependencies commands = [ ("uv sync", "Installing dependencies with UV"), ("uv run python test_sherlock.py", "Running tests"), ] success = True for command, description in commands: if not run_command(command, description): success = False break return success def main(): """Main setup function.""" print("šŸ” Sherlock OSINT Tool Setup") print("=" * 40) # Check if we're in the right directory if not Path("data.json").exists(): print("āŒ data.json not found. Please run this script from the sherlock directory.") sys.exit(1) # Set up environment if setup_environment(): print("\nšŸŽ‰ Setup completed successfully!") print("\nšŸ“‹ Next steps:") print("1. Copy .env.example to .env and configure if needed") print("2. Run the web interface: uv run python app.py") print("3. Or run CLI: uv run python -m sherlock.cli --help") print("\n🌐 Web interface will be available at: http://localhost:7860") else: print("\nāŒ Setup failed. Please check the errors above.") sys.exit(1) if __name__ == "__main__": main()