ngxstat/run-analysis.sh

34 lines
901 B
Bash
Executable file

#!/usr/bin/env bash
set -e
# Ensure virtual environment exists
if [ ! -d ".venv" ]; then
echo "[INFO] Creating virtual environment..."
python3 -m venv .venv
source .venv/bin/activate
echo "[INFO] Installing dependencies..."
pip install --upgrade pip
if [ -f requirements.txt ]; then
pip install -r requirements.txt
else
echo "[WARN] requirements.txt not found, skipping."
fi
else
echo "[INFO] Activating virtual environment..."
source .venv/bin/activate
fi
# Run analysis helpers
echo "[INFO] Checking for missing domains..."
python -m scripts.analyze check-missing-domains
echo "[INFO] Suggesting cache improvements..."
python -m scripts.analyze suggest-cache
echo "[INFO] Detecting threats..."
python -m scripts.analyze detect-threats
# Deactivate to keep cron environment clean
if type deactivate >/dev/null 2>&1; then
deactivate
fi