Files
homelab-agents/scripts/bootstrap-agents.sh
root bd3cda3f1d Update: Bootstrap script now installs init-project helper
- Automatically installs init-project script to ~/.homelab-scripts
- Adds scripts directory to PATH
- Lists available commands after bootstrap
- Enables easy project initialization without manual git setup
2025-11-23 21:38:51 +00:00

79 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Bootstrap script for VPS - Ensures latest homelab agents are available
#
# Usage: source ~/.homelab-setup.sh
# Or add to ~/.bashrc for automatic setup on login
#
# 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)
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"
fi
# Add scripts directory to PATH if not already there
if [[ ":$PATH:" != *":$SCRIPTS_DIR:"* ]]; then
export PATH="$SCRIPTS_DIR:$PATH"
echo "✅ Scripts directory added to PATH"
fi
# 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:"
echo " init-project <name> - 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"