Fix: Bootstrap script now adds scripts directory to PATH permanently

- Automatically adds 'export PATH="$HOME/.homelab-scripts:$PATH"' to ~/.bashrc
- Checks if already present to avoid duplicates
- Also adds to current session PATH immediately
- Eliminates need for manual 'export PATH' commands
- init-project now works in all future shells
This commit is contained in:
root
2025-11-23 21:45:37 +00:00
parent 23aba5df18
commit d49801136a

View File

@@ -1,14 +1,14 @@
#!/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
# Usage: bash <(curl -s http://100.120.125.113:3000/pdm/homelab-agents/raw/branch/main/scripts/bootstrap-agents.sh)
#
# 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
@@ -53,15 +53,32 @@ 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"
echo "✅ init-project installed to $SCRIPTS_DIR"
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"
# 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
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"
@@ -76,4 +93,6 @@ 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"
echo "📋 Agent location: $AGENTS_DIR/agents/sysadmin-session-closer.md"
echo ""
echo "💡 Tip: Run 'source ~/.bashrc' or restart your shell to ensure PATH is updated"