b9e861
#!/bin/bash
b9e861
b9e861
. /etc/sysconfig/kdump
b9e861
b9e861
KDUMP_KERNEL=""
b9e861
KDUMP_INITRD=""
b9e861
b9e861
check() {
b9e861
    if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\
b9e861
        || [ -n "${IN_KDUMP}" ]
b9e861
    then
b9e861
        return 1
b9e861
    fi
b9e861
    return 255
b9e861
}
b9e861
b9e861
depends() {
b9e861
    echo "base shutdown"
b9e861
    return 0
b9e861
}
b9e861
b9e861
prepare_kernel_initrd() {
fd10de
    . /lib/kdump/kdump-lib.sh
fd10de
e97a90
    prepare_kdump_bootinfo
e97a90
e97a90
    # $kernel is a variable from dracut
e97a90
    if [ "$KDUMP_KERNELVER" != $kernel ]; then
e97a90
        dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
e97a90
            "but the initramfs is generated for kernel version '$kernel'"
b9e861
    fi
b9e861
}
b9e861
b9e861
install() {
b9e861
    prepare_kernel_initrd
b9e861
    if [ ! -f "$KDUMP_KERNEL" ]; then
b9e861
        derror "Could not find required kernel for earlykdump," \
b9e861
            "earlykdump will not work!"
b9e861
        return 1
b9e861
    fi
b9e861
    if [ ! -f "$KDUMP_INITRD" ]; then
b9e861
        derror "Could not find required kdump initramfs for earlykdump," \
b9e861
            "please ensure kdump initramfs is generated first," \
b9e861
            "earlykdump will not work!"
b9e861
        return 1
b9e861
    fi
b9e861
b9e861
    inst_multiple tail find cut dirname hexdump
b9e861
    inst_simple "/etc/sysconfig/kdump"
b9e861
    inst_binary "/usr/sbin/kexec"
b9e861
    inst_binary "/usr/bin/gawk" "/usr/bin/awk"
54b5ae
    inst_binary "/usr/bin/logger" "/usr/bin/logger"
54b5ae
    inst_binary "/usr/bin/printf" "/usr/bin/printf"
b9e861
    inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
54b5ae
    inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
b9e861
    inst_hook cmdline 00 "$moddir/early-kdump.sh"
b9e861
    inst_binary "$KDUMP_KERNEL"
b9e861
    inst_binary "$KDUMP_INITRD"
b9e861
e97a90
    ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump"
e97a90
    ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
b9e861
b9e861
    chmod -x "${initdir}/$KDUMP_KERNEL"
b9e861
}