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