kexec-tools/dracut-early-kdump-module-setup.sh
Kairui Song a37f36ad4d Refactor kernel image and initrd detection code
kernel installation is not always in a fixed location /boot, there are
multiple different style of kernel installation, and initramfs location
changes with kernel. The two files should be detected together and adapt
to different style.

To do so we use a list of known installation destinations, and a list
of possible kernel image and initrd names. Iterate the two list to
detect the installation location of the two files. If GRUB is in use,
the BOOT_IMAGE= cmdline from GRUB will also be considered. And also
prefers user specified config if given.

Previous atomic workaround is no longer needed as the new detection
method can cover that case.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-08-27 11:29:17 +08:00

61 lines
1.5 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() {
prepare_kdump_bootinfo
# $kernel is a variable from dracut
if [ "$KDUMP_KERNELVER" != $kernel ]; then
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
"but the initramfs is generated for kernel version '$kernel'"
fi
}
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" "/boot/kernel-earlykdump"
ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
chmod -x "${initdir}/$KDUMP_KERNEL"
}