Skip to content

Commit

Permalink
feat(dracut.sh): add --extra-confdir option
Browse files Browse the repository at this point in the history
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:
rhkdump/kdump-utils#11
rhkdump/kdump-utils#31

Suggested-by: Dave Young <[email protected]>
Signed-off-by: Lichen Liu <[email protected]>
  • Loading branch information
licliu committed Aug 7, 2024
1 parent c520f3a commit 2d8d9e4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 14 additions & 1 deletion dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -385,6 +387,7 @@ rearrange_params() {
--long kmoddir: \
--long conf: \
--long confdir: \
--long extra-confdir: \
--long tmpdir: \
--long sysroot: \
--long stdlog: \
Expand Down Expand Up @@ -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'"
Expand Down Expand Up @@ -914,6 +922,11 @@ elif [[ ! -d $confdir ]]; then
exit 1
fi

if [[ -n $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"
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions man/dracut.8.asc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ Default:
Default:
_/etc/dracut.conf.d_
**--extra-confdir** _<configuration directory>_::
Add an extra configuration directory to use.
**--tmpdir** _<temporary directory>_::
Specify temporary directory to use.
+
Expand Down
4 changes: 2 additions & 2 deletions shell-completion/bash/dracut
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;
Expand Down

0 comments on commit 2d8d9e4

Please sign in to comment.