From 88f787e1f591e4b0411279fd0ffa620266dfb3ef Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Jan 2021 22:23:16 +0800 Subject: [PATCH] module-setup.sh: don't polute the namespace unnecessarily Only source kdump libs when building a kdump initramfs. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-early-kdump-module-setup.sh | 3 ++- dracut-module-setup.sh | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 3b23383..b25d6b5 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -1,7 +1,6 @@ #!/bin/bash . /etc/sysconfig/kdump -. /lib/kdump/kdump-lib.sh KDUMP_KERNEL="" KDUMP_INITRD="" @@ -21,6 +20,8 @@ depends() { } prepare_kernel_initrd() { + . /lib/kdump/kdump-lib.sh + prepare_kdump_bootinfo # $kernel is a variable from dracut diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 5d1f203..9f9220b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1,10 +1,12 @@ #!/bin/bash -. /lib/kdump/kdump-lib.sh +kdump_module_init() { + if ! [[ -d "${initdir}/tmp" ]]; then + mkdir -p "${initdir}/tmp" + fi -if ! [[ -d "${initdir}/tmp" ]]; then - mkdir -p "${initdir}/tmp" -fi + . /lib/kdump/kdump-lib.sh +} check() { [[ $debug ]] && set -x @@ -19,6 +21,8 @@ check() { depends() { local _dep="base shutdown" + kdump_module_init + add_opt_module() { [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" } @@ -825,6 +829,7 @@ kdump_install_systemd_conf() { } install() { + kdump_module_init kdump_install_conf overwrite_sysctl_conf