56 lines
1.7 KiB
Bash
56 lines
1.7 KiB
Bash
#!/bin/bash
|
|
# setup.sh - Main dotfiles setup orchestrator
|
|
# Runs all numbered scripts in sequence
|
|
|
|
set -euo pipefail
|
|
|
|
# Get the absolute path to the directory containing this script
|
|
# This handles symlinks and relative paths to always find the dotfiles root
|
|
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# Source utilities with fallback
|
|
if [ -f "$DOTFILES_DIR/scripts/utils.sh" ]; then
|
|
source "$DOTFILES_DIR/scripts/utils.sh"
|
|
else
|
|
echo "Error: scripts/utils.sh not found! Repository structure is corrupted."
|
|
exit 1
|
|
fi
|
|
|
|
log_info "🔧 Starting dotfiles setup..."
|
|
log_info "Working directory: $DOTFILES_DIR"
|
|
|
|
# Auto-discover and run setup scripts
|
|
if [ -d "$DOTFILES_DIR/scripts" ]; then
|
|
log_info "Running setup scripts..."
|
|
|
|
script_count=0
|
|
# Collect numbered scripts into an array
|
|
# Enable nullglob to ensure no-match yields empty array
|
|
shopt -s nullglob
|
|
scripts=("$DOTFILES_DIR/scripts"/[0-9][0-9]-*.sh)
|
|
shopt -u nullglob
|
|
# Run each discovered script
|
|
for script in "${scripts[@]}"; do
|
|
script_name=$(basename "$script")
|
|
log_info "Running $script_name..."
|
|
if bash "$script" "$DOTFILES_DIR"; then
|
|
log_success "✓ $script_name completed"
|
|
else
|
|
log_error "✗ $script_name failed"
|
|
exit 1
|
|
fi
|
|
((script_count++))
|
|
done
|
|
|
|
if [ $script_count -eq 0 ]; then
|
|
log_warning "No numbered scripts found in scripts/ directory"
|
|
else
|
|
log_success "Completed $script_count setup scripts"
|
|
fi
|
|
else
|
|
log_error "No scripts directory found! Something went wrong with the installation."
|
|
exit 1
|
|
fi
|
|
|
|
log_success "🎉 Dotfiles setup complete!"
|