#!/bin/bash # 🌲 Crumbforest Content Loader # Loads external content (Knowledge Base) from a Git repository CONTENT_DIR="docs" DEFAULT_REPO="https://github.com/example/crumbforest-content.git" echo "🌲 Crumbforest Content Loader" echo "==============================" # Check if git is installed if ! command -v git &> /dev/null; then echo "❌ Git is not installed. Please install git first." exit 1 fi # Get Repo URL if [ -z "$1" ]; then read -p "Enter Content Repository URL (Default: $DEFAULT_REPO): " REPO_URL REPO_URL=${REPO_URL:-$DEFAULT_REPO} else REPO_URL=$1 fi echo "đŸ“Ļ Target Repository: $REPO_URL" echo "📂 Target Directory: $CONTENT_DIR" # Check if directory exists if [ -d "$CONTENT_DIR" ]; then echo "âš ī¸ Directory '$CONTENT_DIR' already exists." read -p "Update existing content (git pull)? [Y/n] " UPDATE UPDATE=${UPDATE:-Y} if [[ "$UPDATE" =~ ^[Yy]$ ]]; then cd "$CONTENT_DIR" echo "âŦ‡ī¸ Pulling changes..." git pull cd .. echo "✅ Content updated." else echo "âšī¸ Operation skipped." fi else echo "âŦ‡ī¸ Cloning content..." git clone "$REPO_URL" "$CONTENT_DIR" echo "✅ Content loaded." fi # Optional: Trigger Re-Index read -p "🔄 Trigger RAG Re-indexing now? [y/N] " REINDEX if [[ "$REINDEX" =~ ^[Yy]$ ]]; then echo "🚀 Triggering Indexer..." ./test.sh quick # Using test.sh purely for connectivity check or call API directly # Ideally should call the API endpoint # curl -X POST http://localhost:8000/api/rag/reindex_all echo "â„šī¸ Please use the Admin Dashboard to re-index content." fi echo "🌲 Done."