8f4abc
#!/usr/bin/bash
8f4abc
8f4abc
COMMAND="$1"
8f4abc
KERNEL_VERSION="$2"
4efe6f
KDUMP_INITRD_DIR_ABS="$3"
8f4abc
KERNEL_IMAGE="$4"
8f4abc
8f4abc
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
8f4abc
    exit 0
8f4abc
fi
8f4abc
4efe6f
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
8f4abc
    KDUMP_INITRD="initrdkdump"
8f4abc
else
4efe6f
    # If `KDUMP_BOOTDIR` is not writable, then the kdump
4efe6f
    # initrd must have been placed at `/var/lib/kdump`
4efe6f
    if [[ ! -w "/boot" ]]; then
4efe6f
        KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
4efe6f
    else
4efe6f
        KDUMP_INITRD_DIR_ABS="/boot"
4efe6f
    fi
8f4abc
    KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
8f4abc
fi
8f4abc
8f4abc
ret=0
8f4abc
case "$COMMAND" in
8f4abc
    add)
8f4abc
        # Do nothing, kdump initramfs is strictly host only
8f4abc
        # and managed by kdump service
8f4abc
        ;;
8f4abc
    remove)
4efe6f
        rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
8f4abc
        ret=$?
8f4abc
        ;;
8f4abc
esac
8f4abc
exit $ret