summaryrefslogtreecommitdiff
path: root/xi/bin/modules-load
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-03-01 23:14:41 +0000
committerdavidovski <david@davidovski.xyz>2022-03-01 23:14:41 +0000
commitea4267fac55c7d8a6093a6b03ff0e9c795786d3e (patch)
tree04905981b9d5ad7a4710c472faf920f3c5e28375 /xi/bin/modules-load
parentefee4ebf43e376a7cd8b8abcef0c70aa90427bb4 (diff)
reorganised
Diffstat (limited to 'xi/bin/modules-load')
-rwxr-xr-xxi/bin/modules-load19
1 files changed, 19 insertions, 0 deletions
diff --git a/xi/bin/modules-load b/xi/bin/modules-load
new file mode 100755
index 0000000..35e73b8
--- /dev/null
+++ b/xi/bin/modules-load
@@ -0,0 +1,19 @@
+#!/bin/sh
+# modules-load [-n] [-v] - modules-load.d(5) compatible kernel module loader
+
+export PATH=/bin:/sbin
+
+{
+# Parameters passed as modules-load= or rd.modules-load= in kernel command line.
+sed -nr 's/,/\n/;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 '^$'
+} |
+# Call modprobe on the list of modules
+tr '\012' '\0' | xargs -0 -r modprobe -ab "$@"