Petr Šabata f5bf49
#!/usr/bin/bash
Petr Šabata f5bf49
Petr Šabata f5bf49
COMMAND="$1"
Petr Šabata f5bf49
KERNEL_VERSION="$2"
5f4c5f
KDUMP_INITRD_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
5f4c5f
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
Petr Šabata f5bf49
    KDUMP_INITRD="initrdkdump"
Petr Šabata f5bf49
else
5f4c5f
    # If `KDUMP_BOOTDIR` is not writable, then the kdump
5f4c5f
    # initrd must have been placed at `/var/lib/kdump`
5f4c5f
    if [[ ! -w "/boot" ]]; then
5f4c5f
        KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
5f4c5f
    else
5f4c5f
        KDUMP_INITRD_DIR_ABS="/boot"
5f4c5f
    fi
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)
5f4c5f
        rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
Petr Šabata f5bf49
        ret=$?
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
esac
Petr Šabata f5bf49
exit $ret