#!/bin/bash # Installation and setup verification script echo "================================================" echo "Network Scanner - Installation Verification" echo "================================================" echo "" # Check Python version echo "1. Checking Python version..." python3 --version if [ $? -ne 0 ]; then echo " ❌ Python 3 not found" exit 1 else echo " ✅ Python 3 found" fi echo "" # Check if virtual environment exists echo "2. Checking for virtual environment..." if [ -d "venv" ]; then echo " ✅ Virtual environment exists" else echo " ⚠️ Virtual environment not found" echo " Creating virtual environment..." python3 -m venv venv echo " ✅ Virtual environment created" fi echo "" # Activate virtual environment echo "3. Activating virtual environment..." source venv/bin/activate echo " ✅ Virtual environment activated" echo "" # Check/Install dependencies echo "4. Checking dependencies..." pip install -q --upgrade pip pip install -q -r requirements.txt echo " ✅ Dependencies installed" echo "" # Check .env file echo "5. Checking configuration..." if [ -f ".env" ]; then echo " ✅ .env file exists" else echo " ⚠️ .env file not found" echo " Creating from .env.example..." cp .env.example .env echo " ✅ .env file created" fi echo "" # Create logs directory echo "6. Checking logs directory..." mkdir -p logs echo " ✅ Logs directory ready" echo "" # Verify file structure echo "7. Verifying project structure..." required_files=( "main.py" "app/__init__.py" "app/config.py" "app/database.py" "app/models.py" "app/schemas.py" "app/scanner/network_scanner.py" "app/scanner/port_scanner.py" "app/scanner/service_detector.py" "app/services/scan_service.py" "app/services/topology_service.py" "app/api/endpoints/scans.py" "app/api/endpoints/hosts.py" "app/api/endpoints/topology.py" "app/api/endpoints/websocket.py" ) all_files_exist=true for file in "${required_files[@]}"; do if [ -f "$file" ]; then echo " ✅ $file" else echo " ❌ $file MISSING" all_files_exist=false fi done echo "" # Test imports echo "8. Testing Python imports..." python3 -c " try: import fastapi import sqlalchemy import pydantic print(' ✅ All core dependencies import successfully') except ImportError as e: print(f' ❌ Import error: {e}') exit(1) " echo "" # Database initialization test echo "9. Testing database initialization..." python3 -c " from app.database import init_db try: init_db() print(' ✅ Database initialized successfully') except Exception as e: print(f' ❌ Database initialization failed: {e}') exit(1) " echo "" # Summary echo "================================================" echo "Installation Verification Complete" echo "================================================" echo "" if [ "$all_files_exist" = true ]; then echo "✅ All required files are present" echo "✅ Dependencies are installed" echo "✅ Database is initialized" echo "" echo "🚀 Ready to start the server!" echo "" echo "Run: python main.py" echo "Or: ./start.sh" echo "" echo "API will be available at: http://localhost:8000" echo "API Docs at: http://localhost:8000/docs" else echo "❌ Some files are missing. Please check the installation." exit 1 fi