2020-07-31 08:47:11 +00:00
|
|
|
#!/usr/bin/bash
|
|
|
|
|
|
|
|
COMMAND="$1"
|
|
|
|
KERNEL_VERSION="$2"
|
2021-04-16 22:31:13 +00:00
|
|
|
KDUMP_INITRD_DIR_ABS="$3"
|
2020-07-31 08:47:11 +00:00
|
|
|
KERNEL_IMAGE="$4"
|
|
|
|
|
|
|
|
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-04-16 22:31:13 +00:00
|
|
|
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
|
2020-07-31 08:47:11 +00:00
|
|
|
KDUMP_INITRD="initrdkdump"
|
|
|
|
else
|
2021-04-16 22:31:13 +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-07-31 08:47:11 +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-04-16 22:31:13 +00:00
|
|
|
rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
|
2020-07-31 08:47:11 +00:00
|
|
|
ret=$?
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit $ret
|