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