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