modules-load.d: cleanups

Move list of directories to a local variable and create the fn variable
to use for an individual file name rather than using path.
This commit is contained in:
William Hubbs 2016-08-25 16:10:45 -05:00
parent 556dbff99d
commit fef6268f8d

View File

@ -16,12 +16,11 @@ depend()
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
} }
modules_dirs="/usr/lib/modules-load.d /run/modules-load.d /etc/modules-load.d"
find_modfiles() find_modfiles()
{ {
local basenames files x y local dirs="/usr/lib/modules-load.d /run/modules-load.d /etc/modules-load.d"
for x in $modules_dirs; do local basenames files fn x y
for x in $dirs; do
[ ! -d $x ] && continue [ ! -d $x ] && continue
for y in $x/*.conf; do for y in $x/*.conf; do
[ -f $y ] && basenames="${basenames}\n${y##*/}" [ -f $y ] && basenames="${basenames}\n${y##*/}"
@ -29,11 +28,11 @@ find_modfiles()
done done
basenames=$(printf "$basenames" | sort -u) basenames=$(printf "$basenames" | sort -u)
for x in $basenames; do for x in $basenames; do
for y in $modules_dirs; do for y in $dirs; do
[ -r $y/$x ] && [ -r $y/$x ] &&
path=$y/$x fn=$y/$x
done done
files="$files $path" files="$files $fn"
done done
echo $files echo $files
} }