Add initial log for Omarchy setup script execution with Zsh configuration

- Created a log file capturing the setup process for the Omarchy script.
- Included detailed steps for installing Zsh and related tools.
- Documented errors encountered during package installations due to database lock.
- Logged successful installations and configuration updates for Zsh and Oh My Zsh.
- Captured user prompts and actions taken during the setup process.
This commit is contained in:
Marco Gallegos
2025-11-15 12:14:55 -06:00
parent 8e370fec39
commit 380b354340
8 changed files with 363 additions and 42 deletions

View File

@@ -36,11 +36,44 @@ log_step() {
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"
}
# Función para crear una copia de seguridad de un archivo o directorio
# Uso: backup_file "/ruta/al/archivo"
backup_file() {
local path_to_backup="$1"
if [[ -e "$path_to_backup" ]]; then
local backup_path="${path_to_backup}.bak_$(date +%F_%T)"
log_warning "Se encontró un archivo existente en '${path_to_backup}'."
log_info "Creando copia de seguridad en: ${backup_path}"
if mv "$path_to_backup" "$backup_path"; then
log_success "Copia de seguridad creada."
else
log_error "No se pudo crear la copia de seguridad. Abortando para evitar pérdida de datos."
return 1
fi
fi
return 0
}
# Función para verificar si un comando existe
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Función para verificar e instalar un paquete con pacman
# Uso: check_and_install_pkg "nombre-del-paquete"
check_and_install_pkg() {
local pkg_name="$1"
# pacman -T es una forma de verificar sin instalar, pero no funciona bien con grupos.
# pacman -Q es más fiable para paquetes individuales.
if ! pacman -Q "$pkg_name" &>/dev/null; then
log_info "Instalando ${pkg_name}..."
sudo pacman -S --noconfirm --needed "$pkg_name" || log_warning "No se pudo instalar ${pkg_name}."
else
log_info "${pkg_name} ya está instalado."
fi
}
# Función para instalar helper AUR si no existe
ensure_aur_helper() {
if command_exists yay; then
@@ -75,4 +108,3 @@ cleanup_orphans() {
sudo pacman -Rns $(pacman -Qtdq) --noconfirm 2>/dev/null || true
log_success "Limpieza completada"
}

View File

@@ -30,7 +30,9 @@ install_docker() {
log_warning "Necesitarás cerrar sesión y volver a iniciar para usar Docker sin sudo"
fi
# Instalar Portainer
echo ""
read -p "¿Deseas instalar Portainer (interfaz web para Docker)? [S/n]: " confirm_portainer
if [[ ! "${confirm_portainer}" =~ ^[Nn]$ ]]; then
log_info "Configurando Portainer..."
# Verificar si Portainer ya está corriendo
@@ -53,10 +55,13 @@ install_docker() {
log_info "Accede a Portainer en: https://localhost:9443"
else
log_error "Error al instalar Portainer"
return 1
# No retornamos error, Docker ya está instalado.
fi
else
log_info "Se omitió la instalación de Portainer."
fi
log_success "Docker y Portainer configurados correctamente"
log_success "Configuración de Docker completada."
return 0
}
@@ -64,4 +69,3 @@ install_docker() {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
install_docker "$@"
fi

View File

@@ -21,9 +21,29 @@ install_zerotier() {
sudo systemctl enable zerotier-one.service
sudo systemctl start zerotier-one.service
log_success "ZeroTier instalado y servicio iniciado"
log_info "Para unirte a una red, ejecuta: sudo zerotier-cli join <NETWORK_ID>"
log_info "Para ver tu ID de ZeroTier: sudo zerotier-cli info"
log_success "ZeroTier instalado y servicio iniciado."
log_info "Tu ID de ZeroTier es: $(sudo zerotier-cli info | awk '{print $3}')"
echo ""
read -p "¿Deseas unirte a una red de ZeroTier ahora? [s/N]: " confirm
if [[ "${confirm}" =~ ^[SsYy]$ ]]; then
read -p "Introduce el ID de la red de ZeroTier: " network_id
if [[ -n "$network_id" ]]; then
log_info "Uniéndote a la red ${network_id}..."
if sudo zerotier-cli join "$network_id"; then
log_success "Solicitud enviada para unirse a la red ${network_id}."
log_warning "Recuerda autorizar este dispositivo en el panel de control de ZeroTier."
else
log_error "No se pudo unir a la red ${network_id}."
fi
else
log_warning "No se introdujo ningún ID de red. Operación cancelada."
fi
else
log_info "Operación omitida."
log_info "Para unirte a una red más tarde, ejecuta:"
log_info "sudo zerotier-cli join <NETWORK_ID>"
fi
return 0
}
@@ -32,4 +52,3 @@ install_zerotier() {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
install_zerotier "$@"
fi

View File

@@ -48,7 +48,10 @@ install_zsh() {
# --- 3. Descargar y configurar el .zshrc personalizado ---
log_info "Descargando configuración .zshrc desde el repositorio..."
if curl -fsSL "${REPO_BASE}/.zshrc" -o "$HOME/.zshrc.omarchy-tmp"; then
# Crear copia de seguridad antes de sobrescribir
backup_file "$HOME/.zshrc" || return 1
if curl -fsSL "${REPO_BASE}/.zshrc" -o "$HOME/.zshrc.omarchy-tmp" && [[ -s "$HOME/.zshrc.omarchy-tmp" ]]; then
mv "$HOME/.zshrc.omarchy-tmp" "$HOME/.zshrc"
log_success "Archivo .zshrc actualizado."
else

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
╔════════════════════════════════════════════════════════════╗
║ 🌀 Omarchy Setup Script — Configuración Modular ║
╚════════════════════════════════════════════════════════════╝
Selecciona las opciones que deseas instalar:
1) 📦 Instalar Aplicaciones (VS Code, VLC, drivers, etc.)
2) 🐚 Configurar Zsh (shell, plugins, config)
3) 🐳 Instalar Docker y Portainer
4) 🌐 Instalar ZeroTier VPN
5) 🖨️ Configurar Impresoras (CUPS)
6) 🖱️ Instalar Tema de Cursor (Bibata)
7) 🎨 Gestionar Temas de Iconos (Papirus, Tela, etc.)
8) 🎬 Instalar DaVinci Resolve (Intel Edition)
F) 💾 Formatear un Disco (FAT32, exFAT, NTFS, ext4)
H) 🎨 Instalar Configuración de Hyprland
A) ✅ Instalar Todo (opciones 1, 2, 3, 4, 5, 6)
0) 🚪 Salir
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Selecciona opción: ⠋ Ejecutando: Configurar Zsh (shell, plugins, config)...
[?25l
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Configuración Completa de Zsh
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▶ Instalando Zsh y herramientas esenciales...
▶ zsh ya está instalado.
▶ zsh-completions ya está instalado.
▶ zsh-syntax-highlighting ya está instalado.
▶ zsh-autosuggestions ya está instalado.
▶ Instalando oh-my-posh...
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
⚠ No se pudo instalar oh-my-posh.
▶ zoxide ya está instalado.
⠙ Ejecutando: Configurar Zsh (shell, plugins, config)...
▶ fastfetch ya está instalado.
▶ yt-dlp ya está instalado.
▶ Instalando nerd-fonts...
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
⚠ No se pudo instalar nerd-fonts.
▶ Instalando unrar...
⠹ Ejecutando: Configurar Zsh (shell, plugins, config)...
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
⚠ No se pudo instalar unrar.
▶ Instalando p7zip...
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
⚠ No se pudo instalar p7zip.
▶ lsof ya está instalado.
▶ Oh My Zsh ya está instalado.
▶ Descargando configuración .zshrc desde el repositorio...
⚠ Se encontró un archivo existente en '/home/marco/.zshrc'.
▶ Creando copia de seguridad en: /home/marco/.zshrc.bak_2025-11-15_12:14:32
✓ Copia de seguridad creada.
⠸ Ejecutando: Configurar Zsh (shell, plugins, config)...
✓ Archivo .zshrc actualizado.
▶ Configurando tema de Oh My Posh (Catppuccin Frappe)...

View File

@@ -86,7 +86,7 @@ declare -A MODULES
MODULES=(
["1"]="apps;run_module_main;📦 Instalar Aplicaciones (VS Code, VLC, drivers, etc.);bg"
["2"]="zsh-config;install_zsh;🐚 Configurar Zsh (shell, plugins, config);bg"
["3"]="docker;install_docker;🐳 Instalar Docker y Portainer;bg"
["3"]="docker;install_docker;🐳 Instalar Docker y Portainer;fg"
["4"]="zerotier;install_zerotier;🌐 Instalar ZeroTier VPN;bg"
["5"]="printer;install_printer;🖨️ Configurar Impresoras (CUPS);bg"
["6"]="mouse_cursor;install_mouse_cursor;🖱️ Instalar Tema de Cursor (Bibata);bg"
@@ -97,7 +97,7 @@ MODULES=(
)
# Módulos a incluir en la opción "Instalar Todo"
INSTALL_ALL_CHOICES=("1" "2" "3" "4" "5" "6")
INSTALL_ALL_CHOICES=("1" "2" "3" "4" "5" "6" "8")
# Función para mostrar el menú
show_menu() {
@@ -161,14 +161,27 @@ install_all() {
local failed=()
for choice in "${INSTALL_ALL_CHOICES[@]}"; do
IFS=';' read -r module_file _ description _ <<< "${MODULES[$choice]}"
log_info "Ejecutando: ${description}"
IFS=';' read -r module_file _ description type <<< "${MODULES[$choice]}"
# Separador visual para cada módulo
echo -e "\n${MAGENTA}────────────────────────────────────────────────────────────${NC}"
log_step "Iniciando Módulo: ${description}"
# Ejecutar con spinner para tareas de fondo (bg)
if [[ "$type" == "bg" ]]; then
start_spinner "Ejecutando: ${description#* }..."
if run_module "${choice}"; then
log_success "Módulo ${module_file} completado"
stop_spinner 0 "Módulo '${description}' finalizado."
else
log_error "Error en el módulo ${module_file}"
stop_spinner 1 "Error en el módulo '${description}'."
failed+=("${module_file}")
fi
else # Ejecutar sin spinner para tareas interactivas (fg)
if ! run_module "${choice}"; then
log_error "Error en el módulo '${description}'."
failed+=("${module_file}")
fi
fi
echo ""
done
@@ -244,8 +257,11 @@ main() {
elif [[ "$choice" == "A" ]]; then
echo -ne "${BOLD}¿Instalar todas las opciones (1, 2, 3, 4, 5, 6)? [s/N]: ${NC} "
log_warning "NOTA: La opción 'Instalar Todo' incluye DaVinci Resolve, que requiere"
log_warning "que hayas descargado el archivo ZIP manualmente en tu carpeta ~/Downloads/."
echo -ne "${BOLD}¿Confirmas que has hecho esto y deseas continuar? [s/N]: ${NC} "
read -r confirm
if [[ "${confirm}" =~ ^[Ss]$ ]]; then
if [[ "${confirm}" =~ ^[SsYy]$ ]]; then
install_all
else
log_info "Instalación cancelada"
@@ -263,4 +279,11 @@ main() {
}
# Ejecutar función principal
main "$@"
# --- Redirección de logs ---
# Crear un nombre de archivo de log con la fecha y hora
LOG_FILE="${SCRIPT_DIR}/omarchy-setup-$(date +%F_%H-%M-%S).log"
# Ejecutar la función principal y redirigir toda la salida (stdout y stderr)
# al archivo de log, mientras también se muestra en la terminal.
main "$@" 2>&1 | tee -a "${LOG_FILE}"