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:
@@ -1,14 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Bootstrap script for VPS - Ensures latest homelab agents are available
|
# Bootstrap script for VPS - Ensures latest homelab agents are available
|
||||||
#
|
#
|
||||||
# Usage: source ~/.homelab-setup.sh
|
# Usage: bash <(curl -s http://100.120.125.113:3000/pdm/homelab-agents/raw/branch/main/scripts/bootstrap-agents.sh)
|
||||||
# Or add to ~/.bashrc for automatic setup on login
|
|
||||||
#
|
#
|
||||||
# This script:
|
# This script:
|
||||||
# - Clones or updates the homelab-agents repo
|
# - Clones or updates the homelab-agents repo
|
||||||
# - Sets up git remotes for pushing VPS work
|
# - Sets up git remotes for pushing VPS work
|
||||||
# - Makes agents available for Claude Code
|
# - Makes agents available for Claude Code
|
||||||
# - Installs helper scripts (init-project)
|
# - Installs helper scripts (init-project)
|
||||||
|
# - Adds scripts to PATH permanently
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -53,15 +53,32 @@ mkdir -p "$SCRIPTS_DIR"
|
|||||||
if [[ -f "$AGENTS_DIR/scripts/init-project.sh" ]]; then
|
if [[ -f "$AGENTS_DIR/scripts/init-project.sh" ]]; then
|
||||||
cp "$AGENTS_DIR/scripts/init-project.sh" "$SCRIPTS_DIR/init-project"
|
cp "$AGENTS_DIR/scripts/init-project.sh" "$SCRIPTS_DIR/init-project"
|
||||||
chmod +x "$SCRIPTS_DIR/init-project"
|
chmod +x "$SCRIPTS_DIR/init-project"
|
||||||
echo "✅ init-project installed"
|
echo "✅ init-project installed to $SCRIPTS_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add scripts directory to PATH if not already there
|
# Add scripts directory to PATH permanently (in ~/.bashrc)
|
||||||
if [[ ":$PATH:" != *":$SCRIPTS_DIR:"* ]]; then
|
BASHRC="$HOME/.bashrc"
|
||||||
export PATH="$SCRIPTS_DIR:$PATH"
|
PATH_EXPORT="export PATH=\"\$HOME/.homelab-scripts:\$PATH\""
|
||||||
echo "✅ Scripts directory added to 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
|
fi
|
||||||
|
|
||||||
|
# Also add to current session PATH
|
||||||
|
export PATH="$SCRIPTS_DIR:$PATH"
|
||||||
|
echo "✅ Scripts directory added to current session PATH"
|
||||||
|
|
||||||
# Verify agents are available
|
# Verify agents are available
|
||||||
if [[ -f "$AGENTS_DIR/agents/sysadmin-session-closer.md" ]]; then
|
if [[ -f "$AGENTS_DIR/agents/sysadmin-session-closer.md" ]]; then
|
||||||
echo "✅ sysadmin-session-closer agent available"
|
echo "✅ sysadmin-session-closer agent available"
|
||||||
@@ -77,3 +94,5 @@ echo " init-project <name> - Initialize a new project with git remote"
|
|||||||
echo " cd ~/.homelab-agents - Browse agents and scripts"
|
echo " cd ~/.homelab-agents - Browse agents and scripts"
|
||||||
echo ""
|
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"
|
||||||
Reference in New Issue
Block a user