unix/fiss

simplifying modules-load util (1e1c7239f70439b34f265aaab84b08c5668c9515)
Repositories | LICENSE

commit 1e1c7239f70439b34f265aaab84b08c5668c9515
parent 05c2bc389098421f7b471c30a0801232422fb2a5
Author: Friedel Schon <[email protected]>
Date:   Mon, 24 Apr 2023 13:14:34 +0200

simplifying modules-load util

Diffstat:
Msrc/script/modules-load.sh19++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/script/modules-load.sh b/src/script/modules-load.sh @@ -4,19 +4,8 @@ # Set the PATH variable to include /bin and /sbin export PATH=/bin:/sbin -# Find modules to load based on modules-load parameters and configuration files -find_modules() { - # Parameters passed as modules-load= or rd.modules-load= in kernel command line. +( sed -nr 's/,/\n/g;s/(.* |^)(rd\.)?modules-load=([^ ]*).*/\3/p' /proc/cmdline - # Find files /{etc,run,usr/lib}/modules-load.d/*.conf in that order. - find -L /etc/modules-load.d /run/modules-load.d /usr/lib/modules-load.d \ - -maxdepth 1 -name '*.conf' -printf '%p %P\n' 2>/dev/null | - # Load each basename only once. - sort -k2 -s | uniq -f1 | cut -d' ' -f1 | - # Read the files, output all non-empty, non-comment lines. - tr '\012' '\0' | xargs -0 -r grep -h -v -e '^[#;]' -e '^$' -} - -# Find and load modules -find_modules | tr '\012' '\0' | xargs -0 -r modprobe -ab "$@" -\ No newline at end of file + grep -hve '^[#;]' -e '^$' /etc/modules-load.d/* /run/modules-load.d/* /usr/lib/modules-load.d/* 2> /dev/null +) | uniq | xargs -r modprobe -ab $@ +\ No newline at end of file