#!/bin/bash
# Integrate BookStack with Gitea for version control

set -e
echo "=== BookStack + Gitea Integration ==="
date

cd /var/www/bookstack

# Create Gitea repository (via API or manually noted)
echo "Repository to create in Gitea: firefrost-documentation"
echo "URL will be: https://git.firefrostgaming.com/firefrost-gaming/firefrost-documentation"

# Configure BookStack Git integration
# Update .env with Git settings
cat >> .env << 'ENVEOF'

# Git Integration
REVISION_ENABLED=true
REVISION_LIMIT=50
DRAWIO_VERSION_CONTROL_ENABLED=true
ENVEOF

# Restart PHP-FPM to apply changes
systemctl restart php8.3-fpm

echo ""
echo "=== Integration Configured ==="
echo "Next steps:"
echo "1. Create 'firefrost-documentation' repo in Gitea"
echo "2. Configure webhook in BookStack settings"
echo "3. Enable auto-commit for page changes"
