#!/bin/bash
# Waits for p443 phase completion, then runs offline post-processing.
# Launch: nohup /root/recon/post_watch.sh >> /root/recon/post_watch.log 2>&1 &
cd /root/recon
for i in $(seq 1 240); do
  if grep -aq 'DONE  p443 rc=' run_scan.log; then
    echo "[$(date -u +%H:%M:%S)] p443 DONE detected, running post-processing"
    python3 extract_domains.py
    bash sector_match.sh
    echo "POST_DONE"
    exit 0
  fi
  sleep 30
done
echo "POST_TIMEOUT after 2h"
