Browse Source

Adding kernel modules script

Fabien Poussin 4 years ago
parent
commit
1724136d99
2 changed files with 35 additions and 0 deletions
  1. 6 0
      doc/linux/services/modules
  2. 29 0
      doc/linux/services/modules.sh

+ 6 - 0
doc/linux/services/modules

@@ -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

+ 29 - 0
doc/linux/services/modules.sh

@@ -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