#!/usr/bin/env bash
set -euo pipefail

if ! command -v hackrf_info >/dev/null 2>&1; then
  echo "[dronedetector-precheck] hackrf_info not found. Install hackrf-tools/hackrf package." >&2
  exit 1
fi

if ! command -v gnuradio-config-info >/dev/null 2>&1; then
  echo "[dronedetector-precheck] gnuradio-config-info not found. Install gnuradio." >&2
  exit 1
fi

if ! python3 -c "import osmosdr" >/dev/null 2>&1; then
  echo "[dronedetector-precheck] Python module osmosdr not importable." >&2
  exit 1
fi

if ! hackrf_info 2>/dev/null | grep -q "Found HackRF"; then
  echo "[dronedetector-precheck] HackRF device was not detected by hackrf_info." >&2
  exit 1
fi
