d45da38dca
Currently when earlykdump failed to install required kernel image or initramfs, it will still install the earlykdump hook and other utils. But it won't work due to the absent of kernel image or kdump initramfs, so the hook and installed utils is meanless. We can't simply fail dracut building, as if earlykdump is included by dracut config file, this may fail kernel update, where kernel image is installed but initramfs failed to generate, and then it will fail booting. So this patch let it skip earlydkump install if anything is missing and give a clean error message to let the user better ware of the situation. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. /etc/sysconfig/kdump
|
|
. /lib/kdump/kdump-lib.sh
|
|
|
|
KDUMP_KERNEL=""
|
|
KDUMP_INITRD=""
|
|
|
|
check() {
|
|
if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\
|
|
|| [ -n "${IN_KDUMP}" ]
|
|
then
|
|
return 1
|
|
fi
|
|
return 255
|
|
}
|
|
|
|
depends() {
|
|
echo "base shutdown"
|
|
return 0
|
|
}
|
|
|
|
prepare_kernel_initrd() {
|
|
KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
|
|
if [ -z "$KDUMP_KERNELVER" ]; then
|
|
kdump_kver=`uname -r`
|
|
else
|
|
kdump_kver=$KDUMP_KERNELVER
|
|
fi
|
|
KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
|
|
KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
|
|
}
|
|
|
|
install() {
|
|
prepare_kernel_initrd
|
|
if [ ! -f "$KDUMP_KERNEL" ]; then
|
|
derror "Could not find required kernel for earlykdump," \
|
|
"earlykdump will not work!"
|
|
return 1
|
|
fi
|
|
if [ ! -f "$KDUMP_INITRD" ]; then
|
|
derror "Could not find required kdump initramfs for earlykdump," \
|
|
"please ensure kdump initramfs is generated first," \
|
|
"earlykdump will not work!"
|
|
return 1
|
|
fi
|
|
|
|
inst_multiple tail find cut dirname hexdump
|
|
inst_simple "/etc/sysconfig/kdump"
|
|
inst_binary "/usr/sbin/kexec"
|
|
inst_binary "/usr/bin/gawk" "/usr/bin/awk"
|
|
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
|
|
inst_hook cmdline 00 "$moddir/early-kdump.sh"
|
|
inst_binary "$KDUMP_KERNEL"
|
|
inst_binary "$KDUMP_INITRD"
|
|
|
|
ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
|
|
ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
|
|
|
|
chmod -x "${initdir}/$KDUMP_KERNEL"
|
|
}
|