55 lines
1.6 KiB
Bash
Executable file
55 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Prevent concurrent executions of this script.
|
|
LOCK_FILE="/tmp/$(basename "$0").lock"
|
|
if [ -e "$LOCK_FILE" ]; then
|
|
echo "[WARN] $(basename "$0") is already running (lock file present)." >&2
|
|
exit 0
|
|
fi
|
|
touch "$LOCK_FILE"
|
|
trap 'rm -f "$LOCK_FILE"' EXIT
|
|
|
|
# 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
|
|
|
|
# Generate reports for all domains combined
|
|
echo "[INFO] Generating aggregate reports..."
|
|
python -m scripts.generate_reports hourly
|
|
python -m scripts.generate_reports daily
|
|
python -m scripts.generate_reports weekly
|
|
python -m scripts.generate_reports monthly
|
|
python -m scripts.generate_reports global
|
|
|
|
# Generate reports for each individual domain
|
|
echo "[INFO] Generating per-domain reports..."
|
|
python -m scripts.generate_reports hourly --all-domains
|
|
python -m scripts.generate_reports daily --all-domains
|
|
python -m scripts.generate_reports weekly --all-domains
|
|
python -m scripts.generate_reports monthly --all-domains
|
|
|
|
# Generate analysis JSON
|
|
echo "[INFO] Generating analysis files..."
|
|
python -m scripts.generate_reports analysis
|
|
|
|
# Generate root index
|
|
python -m scripts.generate_reports index
|
|
|
|
# Deactivate to keep cron environment clean
|
|
if type deactivate >/dev/null 2>&1; then
|
|
deactivate
|
|
fi
|