mirror of
https://github.com/marcogll/omarchy_setup.git
synced 2026-01-13 13:25:16 +00:00
feat: Update disk-format module to enable support for additional file systems and improve logging
This commit is contained in:
106
modules/disk-format.sh
Executable file → Normal file
106
modules/disk-format.sh
Executable file → Normal file
@@ -1,95 +1,47 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
# disk-format.sh - Formateo de discos (FAT32 / exFAT / NTFS / ext4)
|
# disk-format.sh - Soporte para FAT32 / exFAT / NTFS / ext4
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/common.sh"
|
source "${SCRIPT_DIR}/common.sh"
|
||||||
|
|
||||||
run_module_main() {
|
run_module_main() {
|
||||||
log_step "Módulo: Formateo de discos (FAT32 / exFAT / NTFS / ext4)"
|
log_step "Habilitar sistemas de archivos (FAT32 / exFAT / NTFS / ext4)"
|
||||||
|
|
||||||
# Dependencias
|
local pkgs=(
|
||||||
local PKGS=(dosfstools exfatprogs ntfs-3g e2fsprogs)
|
dosfstools
|
||||||
if ! pacman -T "${PKGS[@]}" &>/dev/null; then
|
exfatprogs
|
||||||
log_info "Instalando dependencias necesarias..."
|
ntfs-3g
|
||||||
start_spinner "Instalando: ${PKGS[*]}..."
|
e2fsprogs
|
||||||
if sudo pacman -S --needed --noconfirm "${PKGS[@]}"; then
|
gparted
|
||||||
stop_spinner 0 "Dependencias instaladas."
|
gnome-disk-utility
|
||||||
else
|
)
|
||||||
stop_spinner 1 "No se pudieron instalar las dependencias."
|
|
||||||
return 1
|
local failed=false
|
||||||
|
for pkg in "${pkgs[@]}"; do
|
||||||
|
if ! check_and_install_pkg "$pkg"; then
|
||||||
|
failed=true
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$failed" == true ]]; then
|
||||||
|
log_warning "Algunos paquetes no se pudieron instalar. Revisa los mensajes anteriores."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
log_success "Soporte de sistemas de archivos habilitado."
|
||||||
lsblk -dpno NAME,SIZE,MODEL | sed '/loop/d' | nl -w2 -s'. '
|
echo ""
|
||||||
echo
|
log_info "Formatea manualmente con las utilidades instaladas:"
|
||||||
read -rp "Introduce el dispositivo a formatear (ej. /dev/sdb o /dev/sdb1): " DEVICE
|
echo " • FAT32 : sudo mkfs.fat -F32 /dev/sdXn"
|
||||||
if [[ ! -b "$DEVICE" ]]; then
|
echo " • exFAT : sudo mkfs.exfat /dev/sdXn"
|
||||||
log_error "Dispositivo no válido: $DEVICE"
|
echo " • NTFS : sudo mkfs.ntfs -f /dev/sdXn"
|
||||||
return 1
|
echo " • ext4 : sudo mkfs.ext4 -F /dev/sdXn"
|
||||||
fi
|
log_info "Alternativamente puedes usar GParted o GNOME Disks para un asistente gráfico."
|
||||||
|
return 0
|
||||||
# Desmontar si está montado
|
|
||||||
local mp
|
|
||||||
mp=$(lsblk -no MOUNTPOINT "$DEVICE" | tr -d '[:space:]')
|
|
||||||
if [[ -n "$mp" ]]; then
|
|
||||||
log_warning "El dispositivo está montado en: $mp. Intentando desmontar..."
|
|
||||||
sudo umount "${DEVICE}"* || {
|
|
||||||
log_error "No se pudo desmontar $DEVICE"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Tipos disponibles:"
|
|
||||||
echo " 1) FAT32"
|
|
||||||
echo " 2) exFAT"
|
|
||||||
echo " 3) NTFS"
|
|
||||||
echo " 4) ext4"
|
|
||||||
read -rp "Selecciona tipo [1-4]: " ft
|
|
||||||
case "$ft" in
|
|
||||||
1) FS="fat32"; CMD_BASE="sudo mkfs.fat -F32" ;;
|
|
||||||
2) FS="exfat"; CMD_BASE="sudo mkfs.exfat" ;;
|
|
||||||
3) FS="ntfs"; CMD_BASE="sudo mkfs.ntfs -f" ;;
|
|
||||||
4) FS="ext4"; CMD_BASE="sudo mkfs.ext4 -F" ;;
|
|
||||||
*) log_error "Opción inválida"; return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
read -rp "Etiqueta (opcional): " LABEL
|
|
||||||
echo
|
|
||||||
echo -e "ADVERTENCIA: Se eliminarán todos los datos en ${DEVICE}."
|
|
||||||
read -rp "Escribe 'SI' para confirmar: " confirm
|
|
||||||
if [[ "${confirm}" != "SI" ]]; then
|
|
||||||
log_info "Operación cancelada"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Añadir etiqueta si se proporcionó
|
|
||||||
if [[ -n "${LABEL}" ]]; then
|
|
||||||
case "$FS" in
|
|
||||||
fat32) CMD="${CMD_BASE} -n ${LABEL} ${DEVICE}" ;;
|
|
||||||
exfat) CMD="${CMD_BASE} -n ${LABEL} ${DEVICE}" ;;
|
|
||||||
ntfs) CMD="${CMD_BASE} -L ${LABEL} ${DEVICE}" ;;
|
|
||||||
ext4) CMD="${CMD_BASE} -L ${LABEL} ${DEVICE}" ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
CMD="${CMD_BASE} ${DEVICE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_info "Ejecutando: ${CMD}"
|
|
||||||
if eval "${CMD}"; then
|
|
||||||
log_success "Formateo completado: ${DEVICE} → ${FS}"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
log_error "Fallo al formatear ${DEVICE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ejecutar si se llama directamente
|
# Ejecutar si se llama directamente
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
run_module_main "$@"
|
run_module_main "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -107,11 +107,11 @@ MODULES=(
|
|||||||
["7"]="icon_manager;run_module_main;🎨 Gestionar Temas de Iconos (Papirus, Tela, etc.);fg"
|
["7"]="icon_manager;run_module_main;🎨 Gestionar Temas de Iconos (Papirus, Tela, etc.);fg"
|
||||||
["8"]="davinci-resolve;install_davinci_resolve;🎬 Instalar DaVinci Resolve (Intel Edition);fg"
|
["8"]="davinci-resolve;install_davinci_resolve;🎬 Instalar DaVinci Resolve (Intel Edition);fg"
|
||||||
["H"]="hyprland-config;run_module_main;🎨 Instalar Configuración de Hyprland;bg"
|
["H"]="hyprland-config;run_module_main;🎨 Instalar Configuración de Hyprland;bg"
|
||||||
["F"]="disk-format;run_module_main;💾 Formatear un Disco (FAT32, exFAT, NTFS, ext4);fg"
|
["F"]="disk-format;run_module_main;💾 Habilitar Formatos FAT/exFAT/NTFS/ext4;bg"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Módulos a incluir en la opción "Instalar Todo"
|
# Módulos a incluir en la opción "Instalar Todo"
|
||||||
INSTALL_ALL_CHOICES=("1" "2" "3" "4" "5" "6" "8")
|
INSTALL_ALL_CHOICES=("1" "2" "3" "4" "5" "6" "7" "8" "H")
|
||||||
|
|
||||||
# Función para mostrar el menú
|
# Función para mostrar el menú
|
||||||
show_menu() {
|
show_menu() {
|
||||||
@@ -129,7 +129,7 @@ show_menu() {
|
|||||||
echo -e " ${GREEN}${key})${NC} ${description}"
|
echo -e " ${GREEN}${key})${NC} ${description}"
|
||||||
done | sort -V
|
done | sort -V
|
||||||
|
|
||||||
echo -e " ${GREEN}A)${NC} ✅ Instalar Todo (opciones 1, 2, 3, 4, 5, 6, 8)"
|
echo -e " ${GREEN}A)${NC} ✅ Instalar Todo (1, 2, 3, 4, 5, 6, 7, 8, H)"
|
||||||
echo -e " ${GREEN}0)${NC} 🚪 Salir"
|
echo -e " ${GREEN}0)${NC} 🚪 Salir"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||||
@@ -303,7 +303,7 @@ main() {
|
|||||||
read -p "Presiona Enter para continuar..."
|
read -p "Presiona Enter para continuar..."
|
||||||
|
|
||||||
elif [[ "$choice" == "A" ]]; then
|
elif [[ "$choice" == "A" ]]; then
|
||||||
log_warning "La opción 'Instalar Todo' ejecutará los módulos: 1, 2, 3, 4, 5, 6 y 8."
|
log_warning "La opción 'Instalar Todo' ejecutará los módulos: 1, 2, 3, 4, 5, 6, 7, 8 y H."
|
||||||
log_warning "DaVinci Resolve requiere que el ZIP de instalación esté en ~/Downloads/."
|
log_warning "DaVinci Resolve requiere que el ZIP de instalación esté en ~/Downloads/."
|
||||||
echo -ne "${BOLD}¿Confirmas que deseas instalar todas las opciones ahora? [s/N]: ${NC}"
|
echo -ne "${BOLD}¿Confirmas que deseas instalar todas las opciones ahora? [s/N]: ${NC}"
|
||||||
read -r confirm
|
read -r confirm
|
||||||
|
|||||||
Reference in New Issue
Block a user