mirror of
https://github.com/marcogll/scripts_mg.git
synced 2026-01-13 13:25:15 +00:00
Upgrade Omarchy setup script to version 2.9
Updated the Omarchy setup script to version 2.9, enhancing the installation process for Zsh, Oh My Zsh, and various drivers. Added new features and improved logging and error handling.
This commit is contained in:
@@ -1,496 +1,151 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# =============================================================================
|
# ===============================================================
|
||||||
# Omarchy Setup Script v2.8.1 (Omarchy-MG Fusión)
|
# 🧠 Omarchy Setup Script v2.9 — Intel Edition
|
||||||
# Autor: Marco G. / 2025
|
# ---------------------------------------------------------------
|
||||||
|
# Autor: Marco G.
|
||||||
# Descripción:
|
# Descripción:
|
||||||
# Versión unificada que combina la estética Catppuccin con la robustez
|
# Prepara un entorno completo de trabajo con Zsh, Oh My Zsh,
|
||||||
# y características de versiones anteriores.
|
# Oh My Posh, Homebrew, herramientas de desarrollo, codecs Intel,
|
||||||
# Omite la instalación automática de Nerd Fonts a petición del usuario.
|
# drivers Epson, Logitech y utilidades varias.
|
||||||
# =============================================================================
|
# Este script NO instala DaVinci Resolve, solo deja el sistema listo.
|
||||||
|
# ===============================================================
|
||||||
# Estricto: errores no manejados, variables no definidas y pipes fallidos causan salida
|
|
||||||
set -euo pipefail
|
# ---------------------------------------------------------------
|
||||||
|
# 🧩 Función de seguridad: abortar si algo falla
|
||||||
# =============================================================================
|
# ---------------------------------------------------------------
|
||||||
# COLORES Y CONFIGURACIÓN GLOBAL (Catppuccin Latte Palette)
|
set -e
|
||||||
# =============================================================================
|
trap 'echo "❌ Error en la línea $LINENO. Abortando instalación."; exit 1' ERR
|
||||||
# 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
|
# 🎨 Banner inicial estilo Catppuccin
|
||||||
PEACH="\e[38;5;208m" # #fe640b - naranja/durazno brillante
|
# ---------------------------------------------------------------
|
||||||
GREEN="\e[38;5;70m" # #40a02b - verde medio
|
cat << "EOF"
|
||||||
TEAL="\e[38;5;37m" # #179299 - teal medio
|
╔═════════════════════════════════════════════════════╗
|
||||||
YELLOW="\e[38;5;214m" # #df8e1d - amarillo dorado
|
║ 🧠 Omarchy System Setup v2.9 ║
|
||||||
RED="\e[38;5;196m" # #d20f39 - rojo vibrante
|
║ Intel Iris Xe • Arch Linux ║
|
||||||
BLUE="\e[38;5;27m" # #1e66f5 - azul brillante
|
╚═════════════════════════════════════════════════════╝
|
||||||
RESET="\e[0m"
|
EOF
|
||||||
|
sleep 1
|
||||||
TOTAL_STEPS=11 # Se redujo el número de pasos
|
|
||||||
CURRENT_STEP=0
|
# ---------------------------------------------------------------
|
||||||
NEEDS_REBOOT=false
|
# 🧰 Actualización de sistema y herramientas base
|
||||||
LOG_FILE="$HOME/omarchy-setup.log"
|
# ---------------------------------------------------------------
|
||||||
ERROR_LOG="$HOME/omarchy-errors.log"
|
echo "🔧 Actualizando sistema base..."
|
||||||
|
sudo pacman -Syu --noconfirm
|
||||||
# =============================================================================
|
|
||||||
# LOGGING, UI Y FUNCIONES AUXILIARES
|
echo "📦 Instalando utilidades esenciales..."
|
||||||
# =============================================================================
|
sudo pacman -S --needed --noconfirm \
|
||||||
setup_logging() {
|
base-devel git curl wget zip unzip p7zip unrar tar \
|
||||||
: > "$LOG_FILE"
|
fastfetch nano htop btop eza tree zoxide bat fzf ripgrep \
|
||||||
: > "$ERROR_LOG"
|
python python-pip nodejs npm go \
|
||||||
exec > >(tee -a "$LOG_FILE")
|
docker docker-compose \
|
||||||
exec 2> >(tee -a "$ERROR_LOG" >&2)
|
gnome-keyring openssh lsof ntp \
|
||||||
echo "==================================================================="
|
flatpak
|
||||||
echo "OMARCHY SETUP v2.8.1 - MG Setup Script - $(date '+%Y-%m-%d %H:%M:%S')"
|
|
||||||
echo "==================================================================="
|
# ---------------------------------------------------------------
|
||||||
}
|
# 🖥️ Instalación de controladores Intel Iris Xe
|
||||||
|
# ---------------------------------------------------------------
|
||||||
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"; }
|
echo "🎞️ Instalando controladores y codecs para Intel Iris Xe..."
|
||||||
log_error() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >&2; }
|
sudo pacman -S --needed --noconfirm \
|
||||||
|
mesa libva-intel-driver intel-media-driver \
|
||||||
print_header() {
|
vulkan-intel vulkan-icd-loader \
|
||||||
clear
|
libvdpau-va-gl libva-utils \
|
||||||
echo -e "${MAUVE}╔════════════════════════════════════════════════════════════════╗${RESET}"
|
gstreamer gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly \
|
||||||
echo -e "${MAUVE}║${RESET} ${PEACH}OMARCHY SETUP v2.8.1 - MG Setup Script${RESET} ${MAUVE}║${RESET}"
|
ffmpeg opencl-clang intel-compute-runtime clinfo
|
||||||
echo -e "${MAUVE}╚════════════════════════════════════════════════════════════════╝${RESET}"
|
|
||||||
echo ""
|
# ---------------------------------------------------------------
|
||||||
echo -e "${TEAL}Logs:${RESET} $LOG_FILE"
|
# 🧾 Impresoras Epson (L4150 + Epson Scan2)
|
||||||
echo -e "${RED}Errores:${RESET} $ERROR_LOG"
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo "🖨️ Instalando drivers Epson..."
|
||||||
}
|
sudo pacman -S --needed --noconfirm cups sane simple-scan
|
||||||
|
sudo systemctl enable --now cups.service
|
||||||
progress_bar() {
|
yay -S --needed --noconfirm epson-inkjet-printer-escpr2 epson-scanner-2
|
||||||
local step=$1
|
|
||||||
local total=$2
|
# ---------------------------------------------------------------
|
||||||
local text=$3
|
# 🖱️ Logitech: ltunify y logiops
|
||||||
local percent=$((step * 100 / total))
|
# ---------------------------------------------------------------
|
||||||
local completed=$((step * 40 / total))
|
echo "🖱️ Instalando soporte Logitech..."
|
||||||
local remaining=$((40 - completed))
|
sudo pacman -S --needed --noconfirm ltunify logiops
|
||||||
printf "\r${BLUE}["
|
|
||||||
printf "%${completed}s" | tr ' ' '█'
|
# ---------------------------------------------------------------
|
||||||
printf "%${remaining}s" | tr ' ' '░'
|
# 💻 Aplicaciones gráficas esenciales
|
||||||
printf "]${RESET} ${percent}%% - ${text}"
|
# ---------------------------------------------------------------
|
||||||
}
|
echo "🪟 Instalando aplicaciones gráficas..."
|
||||||
|
sudo pacman -S --needed --noconfirm \
|
||||||
step() {
|
filezilla gedit code cursor telegram-desktop
|
||||||
CURRENT_STEP=$((CURRENT_STEP + 1))
|
|
||||||
echo -e "\n${YELLOW}→ [${CURRENT_STEP}/${TOTAL_STEPS}] $1${RESET}"
|
# ---------------------------------------------------------------
|
||||||
progress_bar $CURRENT_STEP $TOTAL_STEPS "$1"
|
# 🧴 Instalación de Zsh + Oh My Zsh + plugins + Oh My Posh
|
||||||
sleep 0.3
|
# ---------------------------------------------------------------
|
||||||
}
|
echo "💄 Instalando Zsh y entorno de shell..."
|
||||||
|
sudo pacman -S --needed --noconfirm zsh
|
||||||
success() {
|
|
||||||
echo -e "\n${GREEN}✓ $1${RESET}"
|
# Cambiar shell por defecto a Zsh
|
||||||
log "SUCCESS: $1"
|
if [ "$SHELL" != "/bin/zsh" ]; then
|
||||||
}
|
chsh -s /bin/zsh
|
||||||
|
fi
|
||||||
warning() {
|
|
||||||
echo -e "\n${PEACH}⚠ $1${RESET}"
|
# Instalar Oh My Zsh si no existe
|
||||||
log "WARNING: $1"
|
if [ ! -d "$HOME/.oh-my-zsh" ]; then
|
||||||
}
|
echo "🌈 Instalando Oh My Zsh..."
|
||||||
|
RUNZSH=no KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||||
error() {
|
fi
|
||||||
echo -e "\n${RED}✗ $1${RESET}"
|
|
||||||
log_error "$1"
|
# Instalar plugins
|
||||||
}
|
echo "🔌 Instalando plugins de Zsh..."
|
||||||
|
ZSH_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}
|
||||||
info() {
|
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions 2>/dev/null || true
|
||||||
echo -e "${TEAL}ℹ $1${RESET}"
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting 2>/dev/null || true
|
||||||
log "INFO: $1"
|
git clone https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/colorize $ZSH_CUSTOM/plugins/colorize 2>/dev/null || true
|
||||||
}
|
|
||||||
|
# Instalar Oh My Posh
|
||||||
ask_yes_no() {
|
echo "✨ Instalando Oh My Posh..."
|
||||||
local prompt="$1"
|
curl -s https://ohmyposh.dev/install.sh | bash -s
|
||||||
local default="${2:-y}"
|
oh-my-posh font install meslo
|
||||||
[[ "$default" == "y" ]] && prompt+=" [Y/n]: " || prompt+=" [y/N]: "
|
|
||||||
while true; do
|
# ---------------------------------------------------------------
|
||||||
read -p "$(echo -e ${YELLOW}$prompt${RESET})" response
|
# 🍺 Instalación de Homebrew
|
||||||
response=${response:-$default}
|
# ---------------------------------------------------------------
|
||||||
case $response in
|
echo "🍺 Instalando Homebrew..."
|
||||||
[Yy]*) log "USER: $prompt -> YES"; return 0;;
|
if ! command -v brew &>/dev/null; then
|
||||||
[Nn]*) log "USER: $prompt -> NO"; return 1;;
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
*) echo "Por favor responde sí (y) o no (n).";;
|
fi
|
||||||
esac
|
|
||||||
done
|
# ---------------------------------------------------------------
|
||||||
}
|
# 🧩 Configuración de .bashrc (lanza Zsh + Homebrew env)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
check_installed() {
|
echo "⚙️ Ajustando ~/.bashrc..."
|
||||||
pacman -Q "$1" &> /dev/null
|
cat << 'EOBASH' > ~/.bashrc
|
||||||
}
|
# If not running interactively, don't do anything
|
||||||
|
[[ $- != *i* ]] && return
|
||||||
# =============================================================================
|
|
||||||
# FUNCIONES PRINCIPALES DE INSTALACIÓN
|
# Omarchy default rc
|
||||||
# =============================================================================
|
source ~/.local/share/omarchy/default/bash/rc
|
||||||
check_requirements() {
|
|
||||||
step "Verificando requerimientos del sistema"
|
# Lanzar Zsh automáticamente si no estamos ya en Zsh
|
||||||
if [ "$EUID" -eq 0 ]; then error "No ejecutes este script como root."; exit 1; fi
|
if [ -t 1 ] && [ -z "$ZSH_VERSION" ]; then
|
||||||
if ! command -v pacman &> /dev/null; then error "Este script es solo para Arch Linux."; exit 1; fi
|
exec zsh
|
||||||
if ! ping -c 1 archlinux.org &>/dev/null; then error "Sin conexión a Internet. Abortando."; exit 1; fi
|
fi
|
||||||
success "Requerimientos verificados."
|
|
||||||
}
|
# Inicializar Homebrew
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||||
install_packages() {
|
EOBASH
|
||||||
step "Instalando paquetes base y utilidades"
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
local packages=(
|
# 🔐 Activar servicios básicos
|
||||||
git curl wget unzip tar base-devel zsh zsh-completions eza bat zoxide nano
|
# ---------------------------------------------------------------
|
||||||
python-pip python-virtualenv nodejs npm go docker docker-compose
|
echo "🔑 Habilitando servicios..."
|
||||||
teamviewer audacity inkscape yt-dlp ffmpeg playerctl
|
sudo systemctl enable --now docker.service
|
||||||
brightnessctl pamixer lsof net-tools gnome-keyring libsecret seahorse
|
sudo systemctl enable --now ntpd.service
|
||||||
fastfetch htop btop tree p7zip unrar
|
sudo systemctl enable --now gnome-keyring-daemon.service || true
|
||||||
)
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
info "Actualizando base de datos de paquetes..."
|
# ✅ Mensaje final
|
||||||
sudo pacman -Sy --noconfirm || warning "Error al actualizar base de datos, continuando..."
|
# ---------------------------------------------------------------
|
||||||
|
cat << "EOF"
|
||||||
local to_install=()
|
╔═══════════════════════════════════════════════════════════╗
|
||||||
local failed=()
|
║ ✅ Sistema preparado con éxito — Omarchy Setup v2.9 ║
|
||||||
|
║ Reinicia tu sesión o ejecuta 'exec zsh' para aplicar todo ║
|
||||||
# Identificar paquetes que faltan
|
║ Luego copia tu archivo .zshrc de Omarchy v2.1. ║
|
||||||
for pkg in "${packages[@]}"; do
|
╚═══════════════════════════════════════════════════════════╝
|
||||||
if ! check_installed "$pkg"; then
|
EOF
|
||||||
to_install+=("$pkg")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Instalar paquetes faltantes
|
|
||||||
if [ ${#to_install[@]} -gt 0 ]; then
|
|
||||||
info "Instalando ${#to_install[@]} paquetes nuevos..."
|
|
||||||
# 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
|
|
||||||
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)"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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"
|
|
||||||
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"
|
|
||||||
|
|
||||||
# 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" 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
|
|
||||||
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
|
|
||||||
|
|
||||||
# Descargar nuevo .zshrc desde GitHub
|
|
||||||
if curl -fsSL "$ZSHRC_URL" -o "$DEST" 2>/dev/null; then
|
|
||||||
info "Nuevo .zshrc instalado desde GitHub."
|
|
||||||
else
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_teamviewer() {
|
|
||||||
step "Configurando TeamViewer"
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
final_message() {
|
|
||||||
progress_bar $TOTAL_STEPS $TOTAL_STEPS "COMPLETADO"
|
|
||||||
echo -e "\n\n${GREEN}╔════════════════════════════════════════════════════════════════╗${RESET}"
|
|
||||||
echo -e "${GREEN}║${RESET} ${PEACH}CONFIGURACIÓN FINALIZADA${RESET} ${GREEN}║${RESET}"
|
|
||||||
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════╝${RESET}\n"
|
|
||||||
|
|
||||||
if $NEEDS_REBOOT; then
|
|
||||||
echo -e "${RED}⚠ REINICIO REQUERIDO para aplicar todos los cambios (TeamViewer, ZeroTier, etc.).${RESET}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${TEAL}Próximos pasos:${RESET}"
|
|
||||||
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: ${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
|
|
||||||
|
|
||||||
# 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 "$@"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user