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