File size: 3,119 Bytes
c7daaca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
#!/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()
|