- 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
52 lines
1.5 KiB
Bash
52 lines
1.5 KiB
Bash
#!/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!"
|