Petr Šabata f5bf49
#!/usr/bin/bash
Petr Šabata f5bf49
Petr Šabata f5bf49
COMMAND="$1"
Petr Šabata f5bf49
KERNEL_VERSION="$2"
Petr Šabata f5bf49
BOOT_DIR_ABS="$3"
Petr Šabata f5bf49
KERNEL_IMAGE="$4"
Petr Šabata f5bf49
Petr Šabata f5bf49
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
Petr Šabata f5bf49
    exit 0
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
Petr Šabata f5bf49
if [[ -d "$BOOT_DIR_ABS" ]]; then
Petr Šabata f5bf49
    KDUMP_INITRD="initrdkdump"
Petr Šabata f5bf49
else
Petr Šabata f5bf49
    BOOT_DIR_ABS="/boot"
Petr Šabata f5bf49
    KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
Petr Šabata f5bf49
ret=0
Petr Šabata f5bf49
case "$COMMAND" in
Petr Šabata f5bf49
    add)
Petr Šabata f5bf49
        # Do nothing, kdump initramfs is strictly host only
Petr Šabata f5bf49
        # and managed by kdump service
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    remove)
Petr Šabata f5bf49
        rm -f -- "$BOOT_DIR_ABS/$KDUMP_INITRD"
Petr Šabata f5bf49
        ret=$?
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
esac
Petr Šabata f5bf49
exit $ret