Files
dotfiles/install.sh
Eric Turner 988a7acd24 feat: add installation and management scripts
- Add install.sh for main dotfiles installation
- Add install-web.sh for web-based installation
- Add sync.sh for syncing configurations
- Add reset.sh for cleaning up installations

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

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

92 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Main installation script
set -e
DOTFILES_DIR="$HOME/.dotfiles"
BACKUP_DIR="$HOME/.dotfiles_backup_$(date +%Y%m%d_%H%M%S)"
echo "🚀 Setting up dotfiles..."
# Source profile manager library
if [[ -f "$DOTFILES_DIR/lib/profile_manager.sh" ]]; then
source "$DOTFILES_DIR/lib/profile_manager.sh"
echo "🤖 Initializing machine profile..."
MACHINE_PROFILE=$(initialize_profile)
echo ""
else
echo "⚠️ Profile manager not found. Using default package set."
MACHINE_PROFILE="dev-lite"
fi
# Source package manager library
if [[ -f "$DOTFILES_DIR/lib/package_manager.sh" ]]; then
source "$DOTFILES_DIR/lib/package_manager.sh"
else
echo "⚠️ Package manager library not found. Skipping package installation."
fi
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Function to backup and symlink
backup_and_link() {
local source="$1"
local target="$2"
if [[ -e "$target" && ! -L "$target" ]]; then
echo "📦 Backing up existing $target"
mv "$target" "$BACKUP_DIR/"
fi
ln -sf "$source" "$target"
echo "🔗 Linked $source -> $target"
}
# Check and install packages
if command -v install_all_packages >/dev/null 2>&1; then
echo ""
echo "📋 Checking and installing required packages..."
install_all_packages
echo ""
else
echo "⚠️ Package installation functions not available. Continuing with dotfiles setup."
fi
# Symlink shared configs
backup_and_link "$DOTFILES_DIR/git/.gitconfig" "$HOME/.gitconfig"
backup_and_link "$DOTFILES_DIR/vim/.vimrc" "$HOME/.vimrc"
# Detect shell and configure accordingly
CURRENT_SHELL=$(basename "$SHELL")
case "$CURRENT_SHELL" in
"zsh")
backup_and_link "$DOTFILES_DIR/zsh/.zshrc" "$HOME/.zshrc"
echo "✅ Configured for zsh"
;;
"bash")
backup_and_link "$DOTFILES_DIR/bash/.bashrc" "$HOME/.bashrc"
backup_and_link "$DOTFILES_DIR/bash/.bash_profile" "$HOME/.bash_profile"
echo "✅ Configured for bash"
;;
*)
echo "⚠️ Unknown shell: $CURRENT_SHELL"
echo "Manually symlink appropriate shell configs"
;;
esac
echo ""
echo "🎉 Dotfiles installation complete!"
echo "📁 Backups stored in: $BACKUP_DIR"
echo "🔄 Restart your shell or run 'source ~/.${CURRENT_SHELL}rc' to apply changes"
echo ""
echo "📊 Installation summary:"
echo " • Configuration files symlinked"
echo " • Packages checked and installed"
echo " • Shell configuration applied"
echo ""
echo "💡 Useful commands:"
echo " • dotstatus - Check sync status"
echo " • dotsync - Manually sync dotfiles"
echo " • dotson/off - Enable/disable auto-sync"