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