893e0b
#!/bin/bash
893e0b
893e0b
. /etc/sysconfig/kdump
893e0b
. /lib/kdump/kdump-lib.sh
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() {
893e0b
    KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
893e0b
    if [ -z "$KDUMP_KERNELVER" ]; then
893e0b
        kdump_kver=`uname -r`
603de6
        if [ "$kernel" != "$kdump_kver" ]; then
603de6
            dwarn "Using current kernel version '$kdump_kver' for early kdump," \
603de6
                "but the initramfs is generated for kernel version '$kernel'"
603de6
        fi
893e0b
    else
893e0b
        kdump_kver=$KDUMP_KERNELVER
893e0b
    fi
893e0b
    KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
893e0b
    KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
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"
893e0b
    inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
893e0b
    inst_hook cmdline 00 "$moddir/early-kdump.sh"
893e0b
    inst_binary "$KDUMP_KERNEL"
893e0b
    inst_binary "$KDUMP_INITRD"
603de6
603de6
    ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
603de6
    ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
603de6
893e0b
    chmod -x "${initdir}/$KDUMP_KERNEL"
893e0b
}