#!/bin/bash # # test_start_extension.sh - Uruchamia rozszerzenie Rentgen w headless Firefox z weryfikacją # # Ten skrypt jest używany przez Docker runtime stage do: # 1. Uruchomienia Xvfb (wirtualny X server) na display :99 # 2. Uruchomienia web-ext run z verbose loggingiem # 3. Weryfikacji czy extension został poprawnie zainstalowany # 4. Wyświetlenia czytelnego komunikatu o statusie # # Używany w Dockerfile dla łatwego testowania extensiona bez GUI. # Przeniesiony z inline RUN echo do osobnego pliku dla czytelności. # set -e echo "Starting Xvfb on display :99..." Xvfb :99 -screen 0 1024x768x24 & XVFB_PID=$! sleep 2 echo "Xvfb started with PID: $XVFB_PID" echo "Starting web-ext run with verbose logging..." echo "========================================" # Run web-ext with verbose logging and capture output npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log & WEBEXT_PID=$! # Wait for extension installation confirmation echo "Waiting for extension to install..." EXTENSION_CODE_EXECUTED=false for i in {1..30}; do if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then echo "========================================" echo "✓ SUCCESS: Extension installed!" echo "✓ Firefox is running in headless mode" echo "✓ Extension: rentgen@internet-czas-dzialac.pl" # Check if extension code actually executed sleep 2 if grep -q "\[RENTGEN\] Extension initialized successfully!" /tmp/web-ext.log 2>/dev/null; then echo "✓ Extension code executed - webRequest listeners active!" EXTENSION_CODE_EXECUTED=true else echo "⚠ Extension installed but code execution not confirmed yet..." fi echo "✓ Process info:" ps aux | grep -E "(firefox|Xvfb)" | grep -v grep | head -3 echo "========================================" echo "Extension is ready. Press Ctrl+C to stop." break fi sleep 1 done # Show Rentgen-specific logs if found if [ "$EXTENSION_CODE_EXECUTED" = true ]; then echo "" echo "Extension initialization logs:" grep "\[RENTGEN\]" /tmp/web-ext.log 2>/dev/null | head -5 || true echo "" fi # Keep container running and show logs wait $WEBEXT_PID