2021-05-18 06:35:27 +00:00
|
|
|
#!/usr/bin/bash
|
|
|
|
|
|
|
|
COMMAND="$1"
|
|
|
|
KERNEL_VERSION="$2"
|
2021-08-10 12:02:47 +00:00
|
|
|
KDUMP_INITRD_DIR_ABS="$3"
|
2021-05-18 06:35:27 +00:00
|
|
|
KERNEL_IMAGE="$4"
|
|
|
|
|
|
|
|
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-08-10 12:02:47 +00:00
|
|
|
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
|
2021-05-18 06:35:27 +00:00
|
|
|
KDUMP_INITRD="initrdkdump"
|
|
|
|
else
|
2021-08-10 12:02:47 +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
|
2021-05-18 06:35:27 +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-08-10 12:02:47 +00:00
|
|
|
rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
|
2021-05-18 06:35:27 +00:00
|
|
|
ret=$?
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit $ret
|