From 7d992f95305a5a827735c05d891d8523103c86b6 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Wed, 7 Aug 2024 10:13:37 +0800 Subject: [PATCH] feat(dracut.sh): add --extra-confdir option When generating kdump's initrd, we want to keep [omit_]dracutmodules empty and let kdump to handle the modules. And we don't want to affect the first kernel's initrd, so we cannot place our conf file to /etc/dracut.conf.d or /usr/lib/dracut/dracut.conf.d. This patch adds a new option to allow user to add an extra configuration directory to use *.conf files from. After that, kdump will use --extra-confdir /usr/lib/kdump/dracut.conf.d to apply its own dracut conf. See also: https://github.com/rhkdump/kdump-utils/issues/11 https://github.com/rhkdump/kdump-utils/pull/31 Suggested-by: Dave Young Signed-off-by: Lichen Liu --- dracut.sh | 15 ++++++++++++++- man/dracut.8.asc | 3 +++ shell-completion/bash/dracut | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dracut.sh b/dracut.sh index ce523c0a5..e5024eefb 100755 --- a/dracut.sh +++ b/dracut.sh @@ -157,6 +157,8 @@ Creates initial ramdisk images for preloading modules Default: /etc/dracut.conf --confdir [DIR] Specify configuration directory to use *.conf files from. Default: /etc/dracut.conf.d + --extra-confdir [DIR] Add an extra configuration directory to use *.conf + files from. --tmpdir [DIR] Temporary directory to be used instead of default ${TMPDIR:-/var/tmp}. -r, --sysroot [DIR] Specify sysroot directory to collect files from. @@ -385,6 +387,7 @@ rearrange_params() { --long kmoddir: \ --long conf: \ --long confdir: \ + --long extra-confdir: \ --long tmpdir: \ --long sysroot: \ --long stdlog: \ @@ -661,6 +664,11 @@ while :; do PARMS_TO_STORE+=" '$2'" shift ;; + --extra-confdir) + extra_confdir="$2" + PARMS_TO_STORE+=" '$2'" + shift + ;; --tmpdir) tmpdir_l="$2" PARMS_TO_STORE+=" '$2'" @@ -914,6 +922,11 @@ elif [[ ! -d $confdir ]]; then exit 1 fi +if [[ ! -z $extra_confdir ]] && [[ ! -d $extra_confdir ]]; then + printf "%s\n" "dracut[F]: Configuration directory '$extra_confdir' not found." >&2 + exit 1 +fi + # source our config file if [[ -f $conffile ]]; then check_conf_file "$conffile" @@ -922,7 +935,7 @@ if [[ -f $conffile ]]; then fi # source our config dir -for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do +for f in $(dropindirs_sort ".conf" "$confdir" "$extra_confdir" "$dracutbasedir/dracut.conf.d"); do check_conf_file "$f" # shellcheck disable=SC1090 [[ -e $f ]] && . "$f" diff --git a/man/dracut.8.asc b/man/dracut.8.asc index 7162a2905..4360b9318 100644 --- a/man/dracut.8.asc +++ b/man/dracut.8.asc @@ -307,6 +307,9 @@ Default: Default: _/etc/dracut.conf.d_ +**--extra-confdir** __:: + Add an extra configuration directory to use. + **--tmpdir** __:: Specify temporary directory to use. + diff --git a/shell-completion/bash/dracut b/shell-completion/bash/dracut index d54fe5f4e..b868b77e4 100644 --- a/shell-completion/bash/dracut +++ b/shell-completion/bash/dracut @@ -47,14 +47,14 @@ _dracut() { --kernel-cmdline --sshkey --persistent-policy --install-optional --loginstall --uefi-stub --kernel-image --squash-compressor --sysroot --hostonly-mode --hostonly-nics --include --logfile - --uefi-splash-image --sbat + --uefi-splash-image --sbat --extra-confdir ' ) # shellcheck disable=SC2086 if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in - --kmoddir | -k | --fwdir | --confdir | --tmpdir | -r | --sysroot) + --kmoddir | -k | --fwdir | --confdir | --extra-confdir | --tmpdir | -r | --sysroot) comps=$(compgen -d -- "$cur") compopt -o filenames ;;