Adding kernel modules script
authorFabien Poussin <fabien.poussin@gmail.com>
Mon, 26 Aug 2019 10:25:52 +0000 (12:25 +0200)
committerFabien Poussin <fabien.poussin@gmail.com>
Mon, 26 Aug 2019 10:25:52 +0000 (12:25 +0200)
doc/linux/services/modules [new file with mode: 0644]
doc/linux/services/modules.sh [new file with mode: 0755]

diff --git a/doc/linux/services/modules b/doc/linux/services/modules
new file mode 100644 (file)
index 0000000..eeb7bc8
--- /dev/null
@@ -0,0 +1,6 @@
+# Load kernel modules from /etc/modules
+
+type = scripted
+command = /etc/dinit.d/modules.sh start
+restart = false
+depends-on = early-filesystems
diff --git a/doc/linux/services/modules.sh b/doc/linux/services/modules.sh
new file mode 100755 (executable)
index 0000000..425f33b
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+MODULES=/etc/modules
+
+# Check that the kernel has module support.
+[ -e /proc/ksyms -o -e /proc/modules ] || exit 0
+
+case "${1}" in
+    start)
+
+        # Exit if there's no modules file or there are no valid entries
+        [ -r ${MODULES} ] && egrep -qv '^($|#)' ${MODULES} || exit 0
+
+        while read module args; do
+
+            # Ignore comments and blank lines.
+            case "$module" in
+                ""|"#"*) continue ;;
+            esac
+
+            # Try to load the module with its arguments
+            modprobe ${module} ${args} > /dev/null
+        done < ${MODULES}
+        ;;
+    *)
+        echo "Usage: ${0} {start}"
+        exit 1
+        ;;
+esac