Lichen Liu fb93b2
#!/usr/bin/bash
Lichen Liu fb93b2
Lichen Liu fb93b2
COMMAND="$1"
Lichen Liu fb93b2
KERNEL_VERSION="$2"
Lichen Liu fb93b2
Lichen Liu fb93b2
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
Lichen Liu fb93b2
    exit 0
Lichen Liu fb93b2
fi
Lichen Liu fb93b2
Lichen Liu fb93b2
# Currently, fadump is supported only in environments with
Lichen Liu fb93b2
# writable /boot directory.
Lichen Liu fb93b2
if [[ ! -w "/boot" ]]; then
Lichen Liu fb93b2
    exit 0
Lichen Liu fb93b2
fi
Lichen Liu fb93b2
Lichen Liu fb93b2
FADUMP_INITRD="/boot/.initramfs-${KERNEL_VERSION}.img.default"
Lichen Liu fb93b2
FADUMP_INITRD_CHECKSUM="$FADUMP_INITRD.checksum"
Lichen Liu fb93b2
Lichen Liu fb93b2
ret=0
Lichen Liu fb93b2
case "$COMMAND" in
Lichen Liu fb93b2
    add)
Lichen Liu fb93b2
        # Do nothing, fadump initramfs is strictly host only
Lichen Liu fb93b2
        # and managed by kdump service
Lichen Liu fb93b2
        ;;
Lichen Liu fb93b2
    remove)
Lichen Liu fb93b2
        rm -f -- "$FADUMP_INITRD"
Lichen Liu fb93b2
        rm -f -- "$FADUMP_INITRD_CHECKSUM"
Lichen Liu fb93b2
        ret=$?
Lichen Liu fb93b2
        ;;
Lichen Liu fb93b2
esac
Lichen Liu fb93b2
exit $ret