Files
dotfiles/install-web.sh
Eric Turner 27a497a044 fix: change default branch from main to dev in install-web.sh
The repository uses 'dev' as the default branch, not 'main'. Update the
BRANCH variable to prevent clone failures.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 21:22:37 -06:00

171 lines
6.1 KiB
Bash
Executable File

#!/bin/bash
# One-line web installer for Modern Dotfiles Management System
# Usage: curl -fsSL https://your-domain.com/install | bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Configuration
REPO_URL="https://git.turnersrus.com/razzam21/dotfiles"
DOTFILES_DIR="$HOME/.dotfiles"
BRANCH="dev"
# Function to print colored output
print_color() {
local color=$1
local message=$2
echo -e "${color}${message}${NC}"
}
# Function to check prerequisites
check_prerequisites() {
print_color "$BLUE" "🔍 Checking prerequisites..."
# Check if git is installed
if ! command -v git >/dev/null 2>&1; then
print_color "$YELLOW" "⚠️ Git not found. Installing git..."
# Detect OS and install git
if command -v apt >/dev/null 2>&1; then
sudo apt update && sudo apt install -y git
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y git
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y git
elif command -v brew >/dev/null 2>&1; then
brew install git
else
print_color "$RED" "❌ Cannot install git automatically. Please install git and try again."
exit 1
fi
fi
# Check if curl is installed (should be, since we're using it)
if ! command -v curl >/dev/null 2>&1; then
print_color "$RED" "❌ Curl is required but not found."
exit 1
fi
print_color "$GREEN" "✅ Prerequisites satisfied"
}
# Function to backup existing dotfiles
backup_existing() {
if [[ -d "$DOTFILES_DIR" ]]; then
local backup_dir="${DOTFILES_DIR}_backup_$(date +%Y%m%d_%H%M%S)"
print_color "$YELLOW" "📦 Backing up existing dotfiles to: $backup_dir"
mv "$DOTFILES_DIR" "$backup_dir"
fi
}
# Function to clone repository
clone_repository() {
print_color "$BLUE" "📥 Cloning dotfiles repository..."
if git clone --depth 1 -b "$BRANCH" "$REPO_URL" "$DOTFILES_DIR"; then
print_color "$GREEN" "✅ Repository cloned successfully"
else
print_color "$RED" "❌ Failed to clone repository. Please check:"
print_color "$RED" " • Internet connection"
print_color "$RED" " • Repository URL: $REPO_URL"
print_color "$RED" " • Branch: $BRANCH"
exit 1
fi
}
# Function to run installation
run_installation() {
print_color "$BLUE" "🚀 Running dotfiles installation..."
cd "$DOTFILES_DIR"
# Make install script executable
chmod +x install.sh
# Run the installer
if ./install.sh; then
print_color "$GREEN" "🎉 Installation completed successfully!"
else
print_color "$RED" "❌ Installation failed. Check logs in ~/.dotfiles/ for details."
exit 1
fi
}
# Function to show completion message
show_completion() {
print_color "$CYAN" ""
print_color "$CYAN" "╔══════════════════════════════════════════════════════════════╗"
print_color "$CYAN" "║ 🎉 INSTALLATION COMPLETE! 🎉 ║"
print_color "$CYAN" "╚══════════════════════════════════════════════════════════════╝"
print_color "$CYAN" ""
print_color "$GREEN" "Your intelligent dotfiles system is ready to use!"
print_color "$CYAN" ""
print_color "$YELLOW" "💡 Quick commands to try:"
echo " dotstatus - Show sync and system status"
echo " dotprofile - Show your machine profile"
echo " dotpkgs - Show installed packages"
echo " dotupdatecheck - Check for package updates"
echo " l - Enhanced file listing"
echo " g - Git shortcut"
echo " .. - Go up one directory"
print_color "$CYAN" ""
print_color "$YELLOW" "📚 Learn more:"
echo " cat ~/.dotfiles/docs/README.md"
echo " cat ~/.dotfiles/docs/CONFIGURATION.md"
print_color "$CYAN" ""
print_color "$BLUE" "🔄 Restart your shell to activate all features:"
print_color "$BLUE" " exec \$SHELL"
print_color "$CYAN" ""
}
# Main installation function
main() {
print_color "$CYAN" "╔══════════════════════════════════════════════════════════════╗"
print_color "$CYAN" "║ Modern Dotfiles Management System ║"
print_color "$CYAN" "║ One-Line Web Installer ║"
print_color "$CYAN" "╚══════════════════════════════════════════════════════════════╝"
print_color "$CYAN" ""
# Show what will be installed
print_color "$BLUE" "This installer will:"
echo " • Clone the dotfiles repository to ~/.dotfiles"
echo " • Auto-detect your machine type (server/dev/personal)"
echo " • Install appropriate packages for your profile"
echo " • Set up universal aliases and shortcuts"
echo " • Configure automatic syncing and updates"
print_color "$CYAN" ""
# Confirm installation
if [[ -t 0 ]]; then # Only prompt if stdin is a terminal
print_color "$YELLOW" "Continue with installation? [Y/n]: "
read -r response
case "$response" in
[nN]|[nN][oO])
print_color "$YELLOW" "Installation cancelled."
exit 0
;;
esac
fi
print_color "$CYAN" ""
# Run installation steps
check_prerequisites
backup_existing
clone_repository
run_installation
show_completion
}
# Error handling
trap 'print_color "$RED" "❌ Installation failed. Check the error message above."; exit 1' ERR
# Run main function
main "$@"