- 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
58 lines
1.5 KiB
Bash
58 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# scripts/00-check-dependencies.sh - Check for required dependencies
|
|
|
|
set -euo pipefail
|
|
|
|
# Source utilities
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/utils.sh"
|
|
|
|
check_dependencies() {
|
|
log_info "Checking dependencies..."
|
|
|
|
local missing_deps=()
|
|
|
|
# Check for git
|
|
if ! command_exists git; then
|
|
missing_deps+=("git")
|
|
fi
|
|
|
|
# Check for stow
|
|
if ! command_exists stow; then
|
|
missing_deps+=("stow")
|
|
fi
|
|
|
|
if [ ${#missing_deps[@]} -gt 0 ]; then
|
|
log_error "Missing required dependencies: ${missing_deps[*]}"
|
|
echo ""
|
|
echo "Please install the missing dependencies:"
|
|
|
|
for dep in "${missing_deps[@]}"; do
|
|
case "$dep" in
|
|
"git")
|
|
echo " Git:"
|
|
echo " Ubuntu/Debian: sudo apt install git"
|
|
echo " macOS: brew install git"
|
|
echo " Or visit: https://git-scm.com/downloads"
|
|
;;
|
|
"stow")
|
|
echo " GNU Stow:"
|
|
echo " Ubuntu/Debian: sudo apt install stow"
|
|
echo " macOS: brew install stow"
|
|
echo " Or use the alias: install_stow"
|
|
;;
|
|
esac
|
|
echo ""
|
|
done
|
|
|
|
exit 1
|
|
fi
|
|
|
|
log_success "All dependencies satisfied"
|
|
}
|
|
|
|
# Run if called directly
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
check_dependencies
|
|
fi
|