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