#!/bin/bash
# AYN Antivirus Scanner Daemon Launcher (for launchd/systemd)
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
DATA_DIR="${AYN_DATA_DIR:-$HOME/ayn-antivirus-data}"

mkdir -p "$DATA_DIR" "$DATA_DIR/quarantine" "$DATA_DIR/logs"

export PYTHONPATH="$SCRIPT_DIR:${PYTHONPATH:-}"

exec /usr/bin/python3 -c "
import os
data_dir = os.environ.get('AYN_DATA_DIR', os.path.expanduser('~/ayn-antivirus-data'))
os.makedirs(data_dir, exist_ok=True)
from ayn_antivirus.config import Config
from ayn_antivirus.core.scheduler import Scheduler
c = Config()
c.db_path = os.path.join(data_dir, 'signatures.db')
c.quarantine_path = os.path.join(data_dir, 'quarantine')
s = Scheduler(c)
s.schedule_scan('0 0 * * *', 'full')
s.schedule_update(interval_hours=6)
s.run_daemon()
"
