Update Omarchy setup script version to 2.8.1

This commit is contained in:
Marco Gallegos
2025-11-02 11:27:38 -06:00
committed by GitHub
parent 2999dabd22
commit b58fcbb5bf

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# =============================================================================
# Omarchy Setup Script v2.8.3 (Omarchy-MG Fusión)
# Omarchy Setup Script v2.8.1 (Omarchy-MG Fusión)
# Autor: Marco G. / 2025
# Descripción:
# Versión unificada que combina la estética Catppuccin con la robustez
@@ -8,19 +8,21 @@
# Omite la instalación automática de Nerd Fonts a petición del usuario.
# =============================================================================
# Estricto: errores no manejados, variables no definidas y pipes fallidos causan salida
set -euo pipefail
# =============================================================================
# COLORES Y CONFIGURACIÓN GLOBAL (Catppuccin Palette)
# COLORES Y CONFIGURACIÓN GLOBAL (Catppuccin Latte Palette)
# =============================================================================
FLAMINGO="\e[38;5;245m"
MAUVE="\e[38;5;140m"
PEACH="\e[38;5;215m"
GREEN="\e[38;5;121m"
TEAL="\e[38;5;80m"
YELLOW="\e[38;5;229m"
RED="\e[38;5;203m"
BLUE="\e[38;5;75m"
# Latte es el tema claro de Catppuccin - colores más brillantes y vibrantes
FLAMINGO="\e[38;5;174m" # #dd7878 - rosado suave
MAUVE="\e[38;5;135m" # #8839ef - morado vibrante
PEACH="\e[38;5;208m" # #fe640b - naranja/durazno brillante
GREEN="\e[38;5;70m" # #40a02b - verde medio
TEAL="\e[38;5;37m" # #179299 - teal medio
YELLOW="\e[38;5;214m" # #df8e1d - amarillo dorado
RED="\e[38;5;196m" # #d20f39 - rojo vibrante
BLUE="\e[38;5;27m" # #1e66f5 - azul brillante
RESET="\e[0m"
TOTAL_STEPS=11 # Se redujo el número de pasos
@@ -38,17 +40,17 @@ setup_logging() {
exec > >(tee -a "$LOG_FILE")
exec 2> >(tee -a "$ERROR_LOG" >&2)
echo "==================================================================="
echo "OMARCHY SETUP v2.8.3 - $(date '+%Y-%m-%d %H:%M:%S')"
echo "OMARCHY SETUP v2.8.1 - MG Setup Script - $(date '+%Y-%m-%d %H:%M:%S')"
echo "==================================================================="
}
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"; }
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"; }
log_error() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >&2; }
print_header() {
clear
echo -e "${MAUVE}╔════════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${MAUVE}${RESET} ${PEACH}OMARCHY SETUP v2.8.3 - Edición Fusión${RESET} ${MAUVE}${RESET}"
echo -e "${MAUVE}${RESET} ${PEACH}OMARCHY SETUP v2.8.1 - MG Setup Script${RESET} ${MAUVE}${RESET}"
echo -e "${MAUVE}╚════════════════════════════════════════════════════════════════╝${RESET}"
echo ""
echo -e "${TEAL}Logs:${RESET} $LOG_FILE"
@@ -69,11 +71,32 @@ progress_bar() {
printf "]${RESET} ${percent}%% - ${text}"
}
step() { CURRENT_STEP=$((CURRENT_STEP + 1)); echo -e "\n${YELLOW}→ [${CURRENT_STEP}/${TOTAL_STEPS}] $1${RESET}"; progress_bar $CURRENT_STEP $TOTAL_STEPS "$1"; sleep 0.3; }
success() { echo -e "\n${GREEN}$1${RESET}"; log "SUCCESS: $1"; }
warning() { echo -e "\n${PEACH}$1${RESET}"; log "WARNING: $1"; }
error() { echo -e "\n${RED}$1${RESET}"; log_error "$1"; }
info() { echo -e "${TEAL} $1${RESET}"; log "INFO: $1"; }
step() {
CURRENT_STEP=$((CURRENT_STEP + 1))
echo -e "\n${YELLOW}→ [${CURRENT_STEP}/${TOTAL_STEPS}] $1${RESET}"
progress_bar $CURRENT_STEP $TOTAL_STEPS "$1"
sleep 0.3
}
success() {
echo -e "\n${GREEN}$1${RESET}"
log "SUCCESS: $1"
}
warning() {
echo -e "\n${PEACH}$1${RESET}"
log "WARNING: $1"
}
error() {
echo -e "\n${RED}$1${RESET}"
log_error "$1"
}
info() {
echo -e "${TEAL} $1${RESET}"
log "INFO: $1"
}
ask_yes_no() {
local prompt="$1"
@@ -90,7 +113,9 @@ ask_yes_no() {
done
}
check_installed() { pacman -Q "$1" &> /dev/null; }
check_installed() {
pacman -Q "$1" &> /dev/null
}
# =============================================================================
# FUNCIONES PRINCIPALES DE INSTALACIÓN
@@ -105,142 +130,311 @@ check_requirements() {
install_packages() {
step "Instalando paquetes base y utilidades"
local packages=(
git curl wget unzip tar base-devel zsh zsh-completions eza bat zoxide nano
python-pip python-virtualenv nodejs npm go docker docker-compose
teamviewer audacity inkscape oh-my-posh yt-dlp ffmpeg playerctl
teamviewer audacity inkscape yt-dlp ffmpeg playerctl
brightnessctl pamixer lsof net-tools gnome-keyring libsecret seahorse
fastfetch htop btop tree p7zip unrar
)
info "Actualizando base de datos de paquetes..."
sudo pacman -Sy --noconfirm
sudo pacman -Sy --noconfirm || warning "Error al actualizar base de datos, continuando..."
local to_install=()
local failed=()
# Identificar paquetes que faltan
for pkg in "${packages[@]}"; do
! check_installed "$pkg" && to_install+=("$pkg")
if ! check_installed "$pkg"; then
to_install+=("$pkg")
fi
done
# Instalar paquetes faltantes
if [ ${#to_install[@]} -gt 0 ]; then
info "Instalando ${#to_install[@]} paquetes nuevos..."
sudo pacman -S --noconfirm --needed "${to_install[@]}"
# Instalar paquetes de forma individual para mejor manejo de errores
for pkg in "${to_install[@]}"; do
if sudo pacman -S --noconfirm --needed "$pkg" 2>/dev/null; then
info "$pkg instalado correctamente"
else
warning "✗ No se pudo instalar $pkg, continuando..."
failed+=("$pkg")
fi
done
if [ ${#failed[@]} -gt 0 ]; then
warning "Los siguientes paquetes no se pudieron instalar: ${failed[*]}"
fi
else
info "Todos los paquetes base ya están instalados."
fi
# Instalar oh-my-posh desde AUR si no está instalado
if ! command -v oh-my-posh &>/dev/null; then
info "Instalando oh-my-posh desde AUR..."
if command -v yay &>/dev/null; then
yay -S --noconfirm oh-my-posh-bin 2>/dev/null || warning "No se pudo instalar oh-my-posh desde AUR"
else
warning "yay no está disponible, oh-my-posh se instalará después de instalar yay"
fi
fi
# Instalar speedtest-cli si no está disponible
if ! command -v speedtest &>/dev/null; then
sudo pip install --break-system-packages speedtest-cli || true
info "Instalando speedtest-cli..."
sudo pip install --break-system-packages speedtest-cli 2>/dev/null || warning "No se pudo instalar speedtest-cli"
fi
success "Paquetes base instalados."
}
install_yay() {
step "Instalando 'yay' (AUR helper)"
if command -v yay &> /dev/null; then success "yay ya está instalado."; return; fi
# Verificar si yay ya está instalado
if command -v yay &> /dev/null; then
success "yay ya está instalado."
# Intentar instalar oh-my-posh si aún no está instalado
if ! command -v oh-my-posh &>/dev/null; then
info "Instalando oh-my-posh desde AUR..."
yay -S --noconfirm oh-my-posh-bin 2>/dev/null || warning "No se pudo instalar oh-my-posh desde AUR"
fi
return
fi
# Compilar yay desde AUR
info "Clonando y compilando yay desde AUR..."
(
cd /tmp
rm -rf yay
git clone https://aur.archlinux.org/yay.git --quiet
cd yay
makepkg -si --noconfirm --nocheck
)
if command -v yay &> /dev/null; then success "yay instalado correctamente."; else error "Fallo al instalar yay."; exit 1; fi
if git clone https://aur.archlinux.org/yay.git --quiet 2>/dev/null; then
cd yay
makepkg -si --noconfirm --nocheck 2>/dev/null || {
cd /
rm -rf /tmp/yay
return 1
}
else
return 1
fi
) || {
warning "No se pudo instalar yay desde AUR. Continuando sin yay..."
return 0
}
# Verificar instalación y instalar oh-my-posh si es necesario
if command -v yay &> /dev/null; then
success "yay instalado correctamente."
# Instalar oh-my-posh después de instalar yay
if ! command -v oh-my-posh &>/dev/null; then
info "Instalando oh-my-posh desde AUR..."
yay -S --noconfirm oh-my-posh-bin 2>/dev/null || warning "No se pudo instalar oh-my-posh desde AUR"
fi
else
warning "yay no se pudo verificar después de la instalación. Continuando..."
fi
}
setup_docker() {
step "Configurando Docker y permisos de usuario"
sudo systemctl enable --now docker.service
sudo usermod -aG docker "$USER"
success "Docker configurado. Recuerda cerrar y volver a iniciar sesión."
if check_installed docker; then
sudo systemctl enable --now docker.service 2>/dev/null || warning "No se pudo iniciar docker.service"
sudo usermod -aG docker "$USER" 2>/dev/null || warning "No se pudo añadir usuario al grupo docker"
success "Docker configurado. Recuerda cerrar y volver a iniciar sesión."
else
warning "Docker no está instalado, omitiendo configuración."
fi
}
install_ohmyzsh() {
step "Instalando Oh My Zsh y plugins"
if [ -d "$HOME/.oh-my-zsh" ]; then info "Oh My Zsh ya está instalado."; else
RUNZSH=no CHSH=no KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Instalar Oh My Zsh si no está instalado
if [ -d "$HOME/.oh-my-zsh" ]; then
info "Oh My Zsh ya está instalado."
else
info "Instalando Oh My Zsh..."
if RUNZSH=no CHSH=no KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 2>/dev/null; then
info "Oh My Zsh instalado correctamente."
else
warning "No se pudo instalar Oh My Zsh desde el repositorio oficial, continuando..."
fi
fi
# Configurar directorio de plugins personalizados
local ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
mkdir -p "$ZSH_CUSTOM/plugins"
git clone https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_CUSTOM/plugins/zsh-autosuggestions" 2>/dev/null || true
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" 2>/dev/null || true
mkdir -p "$ZSH_CUSTOM/plugins" 2>/dev/null || {
warning "No se pudo crear directorio de plugins, continuando..."
return 0
}
# Instalar plugin de autosugerencias
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_CUSTOM/plugins/zsh-autosuggestions" 2>/dev/null || warning "No se pudo instalar zsh-autosuggestions"
fi
# Instalar plugin de resaltado de sintaxis
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" 2>/dev/null || warning "No se pudo instalar zsh-syntax-highlighting"
fi
success "Oh My Zsh y plugins listos."
}
install_zshrc_and_posh_theme() {
step "Aplicando configuración .zshrc y tema Catppuccin"
local ZSHRC_URL="https://raw.githubusercontent.com/marcogll/scripts_mg/main/omarchy_zsh_setup/.zshrc"
local DEST="$HOME/.zshrc"
# Crear backup del .zshrc existente
if [ -f "$DEST" ]; then
cp "$DEST" "${DEST}.backup.$(date +%Y%m%d_%H%M%S)"
info "Backup del .zshrc existente creado."
if cp "$DEST" "${DEST}.backup.$(date +%Y%m%d_%H%M%S)" 2>/dev/null; then
info "Backup del .zshrc existente creado."
else
warning "No se pudo crear backup del .zshrc, continuando..."
fi
fi
if curl -fsSL "$ZSHRC_URL" -o "$DEST"; then
# Descargar nuevo .zshrc desde GitHub
if curl -fsSL "$ZSHRC_URL" -o "$DEST" 2>/dev/null; then
info "Nuevo .zshrc instalado desde GitHub."
else
error "Fallo al descargar .zshrc. Abortando."
exit 1
warning "Fallo al descargar .zshrc desde GitHub. Puedes configurarlo manualmente más tarde."
fi
# Crear directorio para temas de Oh My Posh
mkdir -p ~/.poshthemes 2>/dev/null || {
warning "No se pudo crear directorio ~/.poshthemes"
}
# Descargar tema Catppuccin Frappe
if curl -fsSL https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/catppuccin_frappe.omp.json -o ~/.poshthemes/catppuccin.omp.json 2>/dev/null; then
info "Tema Catppuccin Frappe descargado."
else
warning "No se pudo descargar el tema Catppuccin Frappe, continuando..."
fi
# Configurar zsh como shell por defecto (solo verificación, sin cambiar interactivamente)
if command -v zsh &>/dev/null; then
local zsh_path=$(which zsh)
if [ -n "$zsh_path" ]; then
# Verificar si el shell actual ya es zsh
current_shell=$(getent passwd "$USER" | cut -d: -f7)
if [ "$current_shell" = "$zsh_path" ]; then
info "El shell por defecto ya es zsh."
else
# Asegurarse de que zsh está en /etc/shells
if ! grep -Fxq "$zsh_path" /etc/shells 2>/dev/null; then
echo "$zsh_path" | sudo tee -a /etc/shells >/dev/null 2>&1 || true
fi
# Informar al usuario sobre cómo cambiar el shell manualmente
info "Para cambiar el shell a zsh, ejecuta manualmente: chsh -s $zsh_path"
fi
fi
success "Zsh listo para usar (cierra y abre la terminal para cambiar al shell)."
else
warning "zsh no está disponible, omitiendo configuración de shell."
fi
mkdir -p ~/.poshthemes
wget https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/catppuccin_frappe.omp.json -O ~/.poshthemes/catppuccin.omp.json -q
info "Tema Catppuccin Frappe descargado."
chsh -s "$(which zsh)" "$USER" || true
success "Zsh configurado como shell por defecto."
}
setup_teamviewer() {
step "Configurando TeamViewer"
sudo systemctl enable --now teamviewerd.service
success "Servicio de TeamViewer habilitado y activo."
NEEDS_REBOOT=true
if check_installed teamviewer; then
sudo systemctl enable --now teamviewerd.service 2>/dev/null || warning "No se pudo iniciar teamviewerd.service"
success "Servicio de TeamViewer habilitado y activo."
NEEDS_REBOOT=true
else
warning "TeamViewer no está instalado, omitiendo configuración."
fi
}
install_zerotier() {
step "Configurando ZeroTier One"
if ! command -v zerotier-cli &> /dev/null; then
yay -S --noconfirm zerotier-one
fi
sudo systemctl enable --now zerotier-one.service
NEEDS_REBOOT=true
if ask_yes_no "¿Deseas unirte a una red ZeroTier ahora?" "y"; then
read -p "$(echo -e ${YELLOW}Ingresa el Network ID: ${RESET})" ZEROTIER_NETWORK
if [ -n "$ZEROTIER_NETWORK" ]; then
info "Enviando solicitud para unirse a la red..."
sudo zerotier-cli join "$ZEROTIER_NETWORK"
warning "Recuerda autorizar este equipo en my.zerotier.com"
if command -v yay &>/dev/null; then
info "Instalando ZeroTier One desde AUR..."
yay -S --noconfirm zerotier-one 2>/dev/null || {
warning "No se pudo instalar ZeroTier One desde AUR"
return 0
}
else
warning "yay no está disponible, no se puede instalar ZeroTier One"
return 0
fi
fi
success "ZeroTier configurado."
if command -v zerotier-cli &>/dev/null; then
sudo systemctl enable --now zerotier-one.service 2>/dev/null || warning "No se pudo iniciar zerotier-one.service"
NEEDS_REBOOT=true
if ask_yes_no "¿Deseas unirte a una red ZeroTier ahora?" "y"; then
read -p "$(echo -e ${YELLOW}Ingresa el Network ID: ${RESET})" ZEROTIER_NETWORK
if [ -n "$ZEROTIER_NETWORK" ]; then
info "Enviando solicitud para unirse a la red..."
sudo zerotier-cli join "$ZEROTIER_NETWORK" 2>/dev/null || warning "No se pudo unir a la red ZeroTier"
warning "Recuerda autorizar este equipo en my.zerotier.com"
fi
fi
success "ZeroTier configurado."
else
warning "ZeroTier One no está disponible, omitiendo configuración."
fi
}
configure_gnome_keyring() {
step "Configurando GNOME Keyring (almacén de contraseñas)"
if ask_yes_no "¿Configurar GNOME Keyring para guardar claves de Git/SSH?" "y"; then
info "Configurando PAM para auto-desbloqueo..."
# Configurar PAM para auto-desbloqueo del Keyring
if ! grep -q "pam_gnome_keyring" /etc/pam.d/login 2>/dev/null; then
echo "auth optional pam_gnome_keyring.so" | sudo tee -a /etc/pam.d/login > /dev/null
echo "session optional pam_gnome_keyring.so auto_start" | sudo tee -a /etc/pam.d/login > /dev/null
fi
# Iniciar gnome-keyring-daemon
eval "$(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh 2>/dev/null)"
export SSH_AUTH_SOCK
success "GNOME Keyring configurado."
fi
}
configure_ssh() {
step "Configurando claves SSH con el agente"
if ask_yes_no "¿Buscar y añadir claves SSH existentes al agente?" "y"; then
# Asegurar que el directorio .ssh existe con permisos correctos
mkdir -p ~/.ssh && chmod 700 ~/.ssh
# Buscar claves SSH válidas
local ssh_keys=()
for key in ~/.ssh/*; do
if [ -f "$key" ] && ! [[ "$key" =~ \.pub$|known_hosts|authorized_keys|config|agent ]]; then
ssh-keygen -l -f "$key" &>/dev/null && ssh_keys+=("$key")
fi
done
# Verificar si se encontraron claves
if [ ${#ssh_keys[@]} -eq 0 ]; then
warning "No se encontraron claves SSH. Genera una con 'ssh-keygen'."
return
fi
# Iniciar gnome-keyring-daemon para SSH
info "Se encontraron ${#ssh_keys[@]} claves. Intentando añadirlas..."
eval "$(gnome-keyring-daemon --start --components=ssh 2>/dev/null)"
export SSH_AUTH_SOCK
# Añadir claves al agente
for key_path in "${ssh_keys[@]}"; do
ssh-add "$key_path" < /dev/null && info "Clave '$(basename "$key_path")' añadida."
done
success "Claves SSH añadidas al agente."
fi
}
@@ -256,35 +450,47 @@ final_message() {
fi
echo -e "${TEAL}Próximos pasos:${RESET}"
echo " 1. ${YELLOW}CIERRA Y VUELVE A ABRIR LA TERMINAL${RESET} o reinicia tu sesión para usar Zsh."
echo " 2. ${PEACH}NOTA:${RESET} La instalación de fuentes fue omitida. Asegúrate de tener una 'Nerd Font'"
echo -e " 1. ${YELLOW}CIERRA Y VUELVE A ABRIR LA TERMINAL${RESET} o reinicia tu sesión para usar Zsh."
echo -e " 2. ${PEACH}NOTA:${RESET} La instalación de fuentes fue omitida. Asegúrate de tener una 'Nerd Font'"
echo " instalada manualmente para que los iconos del prompt se vean correctamente."
echo " 3. La primera vez que uses una clave SSH, se te pedirá la contraseña para guardarla en el Keyring."
echo " 4. Comandos para verificar: 'docker ps', 'teamviewer info', 'speedtest', 'zsh'."
echo -e "\n${MAUVE}🚀 ¡Listo para usar Omarchy con la paleta Catppuccin!${RESET}"
echo " 4. Comandos para verificar: ${BLUE}docker ps${RESET}, ${BLUE}teamviewer info${RESET}, ${BLUE}speedtest${RESET}, ${BLUE}zsh${RESET}."
echo -e "\n${MAUVE}🚀 ¡Listo para usar Omarchy con la paleta Catppuccin!${RESET}\n"
}
# =============================================================================
# EJECUCIÓN PRINCIPAL
# =============================================================================
main() {
# Inicializar logging y mostrar cabecera
setup_logging
print_header
# Verificaciones iniciales
check_requirements
# Instalación de paquetes y herramientas base
install_packages
install_yay
# Configuración de servicios base
setup_docker
# Configuración de Zsh y shell
install_ohmyzsh
install_zshrc_and_posh_theme
setup_teamviewer
# Módulos opcionales
# Configuración de servicios opcionales
setup_teamviewer
install_zerotier
# Configuración de seguridad y claves
configure_gnome_keyring
configure_ssh
# Mensaje final
final_message
}
# Ejecutar script principal
main "$@"