#!/bin/bash # Script to register audit routers in all service main.py files set -e BASE_DIR="/Users/urtzialfaro/Documents/bakery-ia/services" echo "Registering audit routers in service main.py files..." # Function to add audit import and router registration add_audit_to_service() { local service=$1 local main_file="$BASE_DIR/$service/app/main.py" if [ ! -f "$main_file" ]; then echo "⚠️ $service: main.py not found, skipping" return fi # Check if audit is already imported if grep -q "import.*audit" "$main_file"; then echo "✓ $service: audit already imported" else echo "⚠️ $service: needs manual import addition" fi # Check if audit router is already registered if grep -q "service.add_router(audit.router)" "$main_file"; then echo "✓ $service: audit router already registered" else echo "⚠️ $service: needs manual router registration" fi } # Process each service for service in recipes suppliers pos training notification external forecasting; do add_audit_to_service "$service" done echo "" echo "Done! Please check warnings above for services needing manual updates."