1
0
Files
dotfiles/install.sh
Ryan Hamilton 03150e539d feat: implement modular numbered script system
- Add scripts/ directory with numbered execution pattern
- Create 00-check-dependencies.sh for requirement validation
- Create 10-backup-files.sh for conflict handling
- Create 20-setup-stow.sh for symlink creation
- Create 90-post-install.sh for cleanup tasks
- Add scripts/utils.sh with colored logging functions
- Update install.sh to auto-discover and execute numbered scripts
- Remove hardcoded logic in favor of flexible script discovery

Benefits:
- Clean separation of concerns (each script has one job)
- Numbered execution order (SSH/systemd convention)
- Colored output for better UX
- Easy to extend with additional scripts
- Same entry point for all branches
2025-08-04 19:50:21 -05:00

52 lines
1.5 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -euo pipefail
DOTFILES_REPO="https://gitea.purpleraft.com/ryan/dotfiles"
DOTFILES_DIR="$HOME/.dotfiles"
# Source utilities if available
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/scripts/utils.sh" ]; then
source "$SCRIPT_DIR/scripts/utils.sh"
else
# Fallback logging functions if utils not available
log_info() { echo " $1"; }
log_success() { echo "$1"; }
log_warning() { echo "⚠️ $1"; }
log_error() { echo "$1"; }
fi
log_info "🚀 Starting dotfiles installation..."
# Clone or update the repo
if [ -d "$DOTFILES_DIR/.git" ]; then
log_info "Updating existing dotfiles repo..."
git -C "$DOTFILES_DIR" pull --quiet
else
log_info "Cloning dotfiles into $DOTFILES_DIR..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
cd "$DOTFILES_DIR"
# Auto-discover and run setup scripts
if [ -d "scripts" ]; then
log_info "Running setup scripts..."
# Look for numbered scripts and run them in order
for script in scripts/[0-9][0-9]-*.sh; do
if [ -f "$script" ]; then
# Make executable and run
chmod +x "$script" 2>/dev/null || true
script_name=$(basename "$script")
log_info "Running $script_name..."
"$script" "$DOTFILES_DIR"
fi
done
else
log_error "No scripts directory found! Something went wrong with the installation."
exit 1
fi
log_success "Dotfiles install complete!"