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