aur-shield v0.1.0: AI-powered AUR firewall

- FastAPI server with scan/build/repo endpoints
- LLM scanner (Ollama) with regex pre-scan
- makepkg/devtools builder with chroot isolation
- Scan cache with TTL + PKGBUILD hash
- Client installer + safe-yay wrapper
- Docs + config example
This commit is contained in:
arch_agent
2026-08-04 09:35:35 +02:00
commit adee5dfc78
14 changed files with 1368 additions and 0 deletions
+131
View File
@@ -0,0 +1,131 @@
#!/usr/bin/env bash
# AUR-Shield Server Installer
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "╔══════════════════════════════════════════════╗"
echo "║ AUR-Shield Server Installer ║"
echo "╚══════════════════════════════════════════════╝"
echo ""
# Check for Arch Linux
if ! command -v pacman &>/dev/null; then
echo "✗ This script requires Arch Linux (pacman)."
exit 1
fi
# Check for dependencies
echo "Checking dependencies..."
MISSING=()
if ! command -v ollama &>/dev/null; then
MISSING+=("ollama")
fi
if ! command -v makepkg &>/dev/null; then
MISSING+=("base-devel (makepkg)")
fi
if ! command -v python3 &>/dev/null; then
MISSING+=("python3")
fi
if ! command -v git &>/dev/null; then
MISSING+=("git")
fi
if [ ${#MISSING[@]} -gt 0 ]; then
echo "✗ Missing dependencies:"
for dep in "${MISSING[@]}"; do
echo " - $dep"
done
echo ""
echo "Install with: sudo pacman -S ${MISSING[*]}"
exit 1
fi
# Check for devtools (optional but recommended)
DEVTOOLS=""
if ! command -v extra-x86_64-build &>/dev/null; then
echo "⚠ devtools not found — builds will use makepkg directly (less isolation)"
echo " Install with: sudo pacman -S devtools"
echo ""
else
DEVTOOLS="✓ devtools found — builds will use chroot isolation"
fi
# Check for ollama model
echo "Checking Ollama models..."
if ! ollama list 2>/dev/null | grep -q "qwen2.5"; then
echo "⚠ No qwen2.5 model found in Ollama."
echo " Recommended: ollama pull qwen2.5:latest (4.7GB, needs ~6GB VRAM)"
echo " Fallback: ollama pull qwen2.5-coder:3b (1.9GB, needs ~3GB VRAM)"
echo ""
read -rp "Pull qwen2.5:latest now? [Y/n] " PULL
if [[ "${PULL,,}" != "n" ]]; then
ollama pull qwen2.5:latest
fi
fi
# Install Python deps
echo ""
echo "Installing Python dependencies..."
if command -v uv &>/dev/null; then
uv venv "$SCRIPT_DIR/.venv"
uv pip install --python "$SCRIPT_DIR/.venv/bin/python" -e "$SCRIPT_DIR[dev]"
echo "✓ Installed with uv"
else
python3 -m venv "$SCRIPT_DIR/.venv"
"$SCRIPT_DIR/.venv/bin/pip" install -e "$SCRIPT_DIR[dev]"
echo "✓ Installed with pip"
fi
# Create config if not exists
if [ ! -f "$SCRIPT_DIR/config.yaml" ]; then
cp "$SCRIPT_DIR/config.example.yaml" "$SCRIPT_DIR/config.yaml"
echo "✓ Created config.yaml from example"
fi
# Create cache dirs
sudo mkdir -p /var/cache/aur-shield/repo
sudo mkdir -p /var/cache/aur-shield/build
sudo mkdir -p /var/cache/aur-shield/cache
sudo chown -R "$USER" /var/cache/aur-shield/
echo "✓ Created cache directories"
# Create systemd service
SERVICE_FILE="/etc/systemd/system/aur-shield.service"
echo "Creating systemd service..."
sudo tee "$SERVICE_FILE" > /dev/null << EOF
[Unit]
Description=AUR-Shield — AI-powered AUR firewall
After=network.target ollama.service
[Service]
Type=simple
ExecStart=$SCRIPT_DIR/.venv/bin/python -m aur_shield $SCRIPT_DIR/config.yaml
WorkingDirectory=$SCRIPT_DIR
Environment="HOME=$SCRIPT_DIR"
User=$USER
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
echo "✓ Created systemd service"
echo ""
echo "╔══════════════════════════════════════════════╗"
echo "║ Installation complete! ║"
echo "╠══════════════════════════════════════════════╣"
echo "║ ║"
echo "║ Start: systemctl start aur-shield ║"
echo "║ Enable: systemctl enable aur-shield ║"
echo "║ Status: systemctl status aur-shield ║"
echo "║ Logs: journalctl -u aur-shield -f ║"
echo "║ ║"
echo "║ API: http://localhost:8443/api/status ║"
echo "║ ║"
echo "║ Config: $SCRIPT_DIR/config.yaml ║"
echo "║ ║"
echo "╚══════════════════════════════════════════════╝"