v2.10.0: detección dinámica del initrd y validación real del loopback.cfg
generate_grub_entry() ahora: - Detecta el nombre real del initrd en /casper (initrd.lz, initrd.img, initrd) y lo pasa a generate_grub_entry_fallback() como parámetro. - Valida que loopback.cfg tenga contenido útil: si solo contiene "source ..." (como Linux Mint) lo descarta y usa el fallback con paths reales. Corrige la entrada rota de Linux Mint que usaba initrd=/casper/initrd en lugar de initrd=/casper/initrd.lz. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0adcb2a3f5
commit
5efdfd140e
+17
-8
@@ -5,7 +5,7 @@
|
|||||||
# Autor: Lic. Ricardo MONLA
|
# Autor: Lic. Ricardo MONLA
|
||||||
# Email: rmonla@gmail.com
|
# Email: rmonla@gmail.com
|
||||||
# GitHub: https://github.com/ricardomonla/rm-MULTIBOOT
|
# GitHub: https://github.com/ricardomonla/rm-MULTIBOOT
|
||||||
# Versión: 2.9.0
|
# Versión: 2.10.0
|
||||||
# Licencia: MIT
|
# Licencia: MIT
|
||||||
#
|
#
|
||||||
# Uso: sudo ./rm-multiboot.sh
|
# Uso: sudo ./rm-multiboot.sh
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# ─── Constantes ───────────────────────────────────────────────────────────────
|
# ─── Constantes ───────────────────────────────────────────────────────────────
|
||||||
readonly SCRIPT_VERSION="2.9.0"
|
readonly SCRIPT_VERSION="2.10.0"
|
||||||
readonly SCRIPT_AUTHOR="Lic. Ricardo MONLA"
|
readonly SCRIPT_AUTHOR="Lic. Ricardo MONLA"
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
readonly ISOS_CONF="$SCRIPT_DIR/isos.conf"
|
readonly ISOS_CONF="$SCRIPT_DIR/isos.conf"
|
||||||
@@ -1340,12 +1340,20 @@ generate_grub_entry() {
|
|||||||
part_uuid=$(lsblk -no UUID "$MULTIBOOT_DEV" 2>/dev/null | head -1)
|
part_uuid=$(lsblk -no UUID "$MULTIBOOT_DEV" 2>/dev/null | head -1)
|
||||||
local entry_file="$ENTRIES_DIR/${label}.cfg"
|
local entry_file="$ENTRIES_DIR/${label}.cfg"
|
||||||
|
|
||||||
# Verificar si la ISO tiene loopback.cfg nativo
|
# Montar la ISO para inspeccionar su contenido
|
||||||
local tmp_mnt has_loopback=false
|
local tmp_mnt has_loopback=false casper_initrd="initrd"
|
||||||
tmp_mnt=$(mktemp -d)
|
tmp_mnt=$(mktemp -d)
|
||||||
modprobe loop 2>/dev/null || true
|
modprobe loop 2>/dev/null || true
|
||||||
if mount -o loop,ro "$ISO_DIR/$iso_name" "$tmp_mnt" 2>/dev/null; then
|
if mount -o loop,ro "$ISO_DIR/$iso_name" "$tmp_mnt" 2>/dev/null; then
|
||||||
[[ -f "$tmp_mnt/boot/grub/loopback.cfg" ]] && has_loopback=true
|
local lbc="$tmp_mnt/boot/grub/loopback.cfg"
|
||||||
|
# loopback.cfg válido: existe y tiene contenido real (no solo "source ...")
|
||||||
|
if [[ -f "$lbc" ]] && grep -qv '^\s*\(source\|#\|$\)' "$lbc" 2>/dev/null; then
|
||||||
|
has_loopback=true
|
||||||
|
fi
|
||||||
|
# Detectar nombre real del initrd en /casper (puede ser .lz, .img o sin extensión)
|
||||||
|
local n; for n in initrd.lz initrd.img initrd; do
|
||||||
|
[[ -f "$tmp_mnt/casper/$n" ]] && { casper_initrd="$n"; break; }
|
||||||
|
done
|
||||||
umount "$tmp_mnt" 2>/dev/null || true
|
umount "$tmp_mnt" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
rmdir "$tmp_mnt" 2>/dev/null || true
|
rmdir "$tmp_mnt" 2>/dev/null || true
|
||||||
@@ -1367,21 +1375,22 @@ menuentry "$distro — $iso_name" --class linux {
|
|||||||
CFG
|
CFG
|
||||||
ok "Entrada GRUB: loopback.cfg nativo"
|
ok "Entrada GRUB: loopback.cfg nativo"
|
||||||
else
|
else
|
||||||
generate_grub_entry_fallback "$iso_name" "$distro" "$part_uuid" "$entry_file"
|
generate_grub_entry_fallback "$iso_name" "$distro" "$part_uuid" "$entry_file" "$casper_initrd"
|
||||||
warn "Entrada GRUB: modo genérico (sin loopback.cfg en la ISO)"
|
warn "Entrada GRUB: modo genérico (sin loopback.cfg válido)"
|
||||||
fi
|
fi
|
||||||
ok "Entrada guardada: $(basename "$entry_file")"
|
ok "Entrada guardada: $(basename "$entry_file")"
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_grub_entry_fallback() {
|
generate_grub_entry_fallback() {
|
||||||
local iso_name="$1" distro="$2" part_uuid="$3" entry_file="$4"
|
local iso_name="$1" distro="$2" part_uuid="$3" entry_file="$4"
|
||||||
|
local casper_initrd="${5:-initrd}"
|
||||||
local d="${distro,,}"
|
local d="${distro,,}"
|
||||||
local vmlinuz initrd params
|
local vmlinuz initrd params
|
||||||
|
|
||||||
case "$d" in
|
case "$d" in
|
||||||
*ubuntu*|*mint*|*pop*|*zorin*|*elementary*|*kubuntu*|*xubuntu*|*lubuntu*)
|
*ubuntu*|*mint*|*pop*|*zorin*|*elementary*|*kubuntu*|*xubuntu*|*lubuntu*)
|
||||||
vmlinuz="/casper/vmlinuz"
|
vmlinuz="/casper/vmlinuz"
|
||||||
initrd="/casper/initrd"
|
initrd="/casper/$casper_initrd"
|
||||||
params="boot=casper iso-scan/filename=/isos/$iso_name quiet splash"
|
params="boot=casper iso-scan/filename=/isos/$iso_name quiet splash"
|
||||||
;;
|
;;
|
||||||
*netinst*|*netinstall*)
|
*netinst*|*netinstall*)
|
||||||
|
|||||||
Reference in New Issue
Block a user