From d5491c9169d48dd55b3c5c7326d3e16cfe550f3c Mon Sep 17 00:00:00 2001 From: Shreenidhi Shedi Date: Sat, 18 Feb 2023 18:11:51 +0530 Subject: [PATCH] feat(dracut.sh): support multiple config dirs Configuration can come from many places, users should not be restricted to keep all configuration files in one directory. Signed-off-by: Shreenidhi Shedi --- dracut.sh | 30 +++++++++++++++++++----------- man/dracut.8.asc | 4 ++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dracut.sh b/dracut.sh index 0c0f85c2db..0c764061a2 100755 --- a/dracut.sh +++ b/dracut.sh @@ -154,8 +154,9 @@ Creates initial ramdisk images for preloading modules -q, --quiet Decrease verbosity level. -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf - --confdir [DIR] Specify configuration directory to use *.conf files - from. Default: /etc/dracut.conf.d + --confdir [LIST] Specify a space separated list of configuration + directories to use *.conf files from. + Default: /etc/dracut.conf.d --tmpdir [DIR] Temporary directory to be used instead of default ${TMPDIR:-/var/tmp}. -r, --sysroot [DIR] Specify sysroot directory to collect files from. @@ -668,7 +669,7 @@ while :; do shift ;; --confdir) - confdir="$2" + confdirs_l=("$2") PARMS_TO_STORE+=" '$2'" shift ;; @@ -911,15 +912,21 @@ elif [[ ! -e $conffile ]]; then exit 1 fi -if [[ -z $confdir ]]; then +if [ ${#confdirs_l[@]} -eq 0 ]; then if [[ $allowlocal ]]; then - confdir="$dracutbasedir/dracut.conf.d" + confdirs="$dracutbasedir/dracut.conf.d" else - confdir="$dracutsysrootdir/etc/dracut.conf.d" + confdirs="$dracutsysrootdir/etc/dracut.conf.d" fi -elif [[ ! -d $confdir ]]; then - printf "%s\n" "dracut[F]: Configuration directory '$confdir' not found." >&2 - exit 1 +else + # shellcheck disable=SC2068 + for d in ${confdirs_l[@]}; do + if [[ ! -d $d ]]; then + printf "%s\n" "dracut[F]: Configuration directory '$d' not found." >&2 + exit 1 + fi + confdirs+=" $d" + done fi # source our config file @@ -929,8 +936,9 @@ if [[ -f $conffile ]]; then . "$conffile" fi -# source our config dir -for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do +# source config files from all config dirs +# shellcheck disable=SC2086 +for f in $(dropindirs_sort ".conf" $confdirs "$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 5c2b147ab2..3eddb5a05d 100644 --- a/man/dracut.8.asc +++ b/man/dracut.8.asc @@ -305,8 +305,8 @@ example: Default: _/etc/dracut.conf_ -**--confdir** __:: - Specify configuration directory to use. +**--confdir** __:: + Specify a space-separated list of dracut configuration directories to use. + Default: _/etc/dracut.conf.d_