2020-10-15 12:45:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
. /etc/sysconfig/kdump
|
|
|
|
|
|
|
|
KDUMP_KERNEL=""
|
|
|
|
KDUMP_INITRD=""
|
|
|
|
|
|
|
|
check() {
|
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
upstream: fedora
resolves: bz2003832
conflict:
function load_kdump_kernel_key() not presented in rhel9,
so related patch hunk are removed.
commit 70978c00e5a573f0901ac404067eaea2c6536370
Author: Kairui Song <kasong@redhat.com>
Date: Wed Sep 8 17:20:51 2021 +0800
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they
only run in first kernel and depend on dracut, and dracut depends
on bash. So use '[[ ]]' to replace '[ ]'.
This is a batch update done with following command:
`sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh`
and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually.
See https://tldp.org/LDP/abs/html/testconstructs.html for more details
on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'.
This will also help shfmt to clean up the code in later commits.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 13:13:59 +00:00
|
|
|
if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]]\
|
|
|
|
|| [[ -n "${IN_KDUMP}" ]]
|
2020-10-15 12:45:57 +00:00
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 255
|
|
|
|
}
|
|
|
|
|
|
|
|
depends() {
|
|
|
|
echo "base shutdown"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_kernel_initrd() {
|
2021-01-22 08:12:00 +00:00
|
|
|
. /lib/kdump/kdump-lib.sh
|
|
|
|
|
2020-10-15 12:45:57 +00:00
|
|
|
prepare_kdump_bootinfo
|
|
|
|
|
|
|
|
# $kernel is a variable from dracut
|
2021-11-09 13:27:55 +00:00
|
|
|
if [[ "$KDUMP_KERNELVER" != "$kernel" ]]; then
|
2020-10-15 12:45:57 +00:00
|
|
|
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
|
|
|
|
"but the initramfs is generated for kernel version '$kernel'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
|
|
|
prepare_kernel_initrd
|
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
upstream: fedora
resolves: bz2003832
conflict:
function load_kdump_kernel_key() not presented in rhel9,
so related patch hunk are removed.
commit 70978c00e5a573f0901ac404067eaea2c6536370
Author: Kairui Song <kasong@redhat.com>
Date: Wed Sep 8 17:20:51 2021 +0800
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they
only run in first kernel and depend on dracut, and dracut depends
on bash. So use '[[ ]]' to replace '[ ]'.
This is a batch update done with following command:
`sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh`
and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually.
See https://tldp.org/LDP/abs/html/testconstructs.html for more details
on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'.
This will also help shfmt to clean up the code in later commits.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 13:13:59 +00:00
|
|
|
if [[ ! -f "$KDUMP_KERNEL" ]]; then
|
2020-10-15 12:45:57 +00:00
|
|
|
derror "Could not find required kernel for earlykdump," \
|
|
|
|
"earlykdump will not work!"
|
|
|
|
return 1
|
|
|
|
fi
|
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
upstream: fedora
resolves: bz2003832
conflict:
function load_kdump_kernel_key() not presented in rhel9,
so related patch hunk are removed.
commit 70978c00e5a573f0901ac404067eaea2c6536370
Author: Kairui Song <kasong@redhat.com>
Date: Wed Sep 8 17:20:51 2021 +0800
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they
only run in first kernel and depend on dracut, and dracut depends
on bash. So use '[[ ]]' to replace '[ ]'.
This is a batch update done with following command:
`sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh`
and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually.
See https://tldp.org/LDP/abs/html/testconstructs.html for more details
on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'.
This will also help shfmt to clean up the code in later commits.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 13:13:59 +00:00
|
|
|
if [[ ! -f "$KDUMP_INITRD" ]]; then
|
2020-10-15 12:45:57 +00:00
|
|
|
derror "Could not find required kdump initramfs for earlykdump," \
|
|
|
|
"please ensure kdump initramfs is generated first," \
|
|
|
|
"earlykdump will not work!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
inst_multiple tail find cut dirname hexdump
|
|
|
|
inst_simple "/etc/sysconfig/kdump"
|
|
|
|
inst_binary "/usr/sbin/kexec"
|
|
|
|
inst_binary "/usr/bin/gawk" "/usr/bin/awk"
|
2020-11-05 05:34:29 +00:00
|
|
|
inst_binary "/usr/bin/logger" "/usr/bin/logger"
|
|
|
|
inst_binary "/usr/bin/printf" "/usr/bin/printf"
|
2020-10-15 12:45:57 +00:00
|
|
|
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
|
2020-11-05 05:34:29 +00:00
|
|
|
inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
|
2020-10-15 12:45:57 +00:00
|
|
|
inst_hook cmdline 00 "$moddir/early-kdump.sh"
|
|
|
|
inst_binary "$KDUMP_KERNEL"
|
|
|
|
inst_binary "$KDUMP_INITRD"
|
|
|
|
|
|
|
|
ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump"
|
|
|
|
ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
|
|
|
|
|
|
|
|
chmod -x "${initdir}/$KDUMP_KERNEL"
|
|
|
|
}
|