#!/bin/bash # Bootstrap script for VPS - Ensures latest homelab agents are available # # Usage: source <(curl -s http://100.120.125.113:3000/pdm/homelab-agents/raw/branch/main/scripts/bootstrap-agents.sh) # # IMPORTANT: Use 'source' not 'bash' so PATH updates take effect immediately! # # This script: # - Clones or updates the homelab-agents repo # - Sets up git remotes for pushing VPS work # - Makes agents available for Claude Code # - Installs helper scripts (init-project) # - Adds scripts to PATH permanently set -e GITEA_URL="http://100.120.125.113:3000" AGENTS_REPO="$GITEA_URL/pdm/homelab-agents.git" AGENTS_DIR="$HOME/.homelab-agents" SCRIPTS_DIR="$HOME/.homelab-scripts" echo "🔧 Bootstrapping homelab agents..." # Create agents directory if needed if [[ ! -d "$AGENTS_DIR" ]]; then echo "📦 Cloning homelab-agents from Gitea..." git clone "$AGENTS_REPO" "$AGENTS_DIR" echo "✅ homelab-agents cloned to $AGENTS_DIR" else echo "📂 homelab-agents directory exists, updating..." cd "$AGENTS_DIR" # Ensure git is initialized if [[ ! -d .git ]]; then git init git remote add origin "$AGENTS_REPO" fi # Update remote URL in case it changed git remote set-url origin "$AGENTS_REPO" 2>/dev/null || git remote add origin "$AGENTS_REPO" # Pull latest agents if git pull origin main 2>/dev/null; then echo "✅ homelab-agents updated to latest version" else echo "⚠️ Could not pull from main branch (might not exist yet)" fi fi # Install helper scripts echo "" echo "📋 Installing helper scripts..." mkdir -p "$SCRIPTS_DIR" if [[ -f "$AGENTS_DIR/scripts/init-project.sh" ]]; then cp "$AGENTS_DIR/scripts/init-project.sh" "$SCRIPTS_DIR/init-project" chmod +x "$SCRIPTS_DIR/init-project" echo "✅ init-project installed to $SCRIPTS_DIR" fi # Add scripts directory to PATH permanently (in ~/.bashrc) BASHRC="$HOME/.bashrc" PATH_EXPORT="export PATH=\"\$HOME/.homelab-scripts:\$PATH\"" if [[ -f "$BASHRC" ]]; then if ! grep -q "homelab-scripts" "$BASHRC"; then echo "" >> "$BASHRC" echo "# Homelab scripts directory" >> "$BASHRC" echo "$PATH_EXPORT" >> "$BASHRC" echo "✅ Added scripts directory to ~/.bashrc" else echo "✅ Scripts directory already in ~/.bashrc" fi else # Create ~/.bashrc if it doesn't exist echo "$PATH_EXPORT" > "$BASHRC" echo "✅ Created ~/.bashrc with scripts directory" fi # Also add to current session PATH (this is why we use 'source' not 'bash') export PATH="$SCRIPTS_DIR:$PATH" echo "✅ Scripts directory added to current session PATH" # Verify agents are available if [[ -f "$AGENTS_DIR/agents/sysadmin-session-closer.md" ]]; then echo "✅ sysadmin-session-closer agent available" else echo "⚠️ Warning: sysadmin-session-closer.md not found" fi echo "" echo "✨ Homelab agents bootstrap complete!" echo "" echo "📚 Available commands (ready to use now):" echo " init-project - Initialize a new project with git remote" echo " cd ~/.homelab-agents - Browse agents and scripts" echo "" echo "📋 Agent location: $AGENTS_DIR/agents/sysadmin-session-closer.md"