Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | ### BEGIN INIT INFO |
| 3 | # Provides: module-init-tools |
| 4 | # Required-Start: |
| 5 | # Required-Stop: |
| 6 | # Should-Start: checkroot |
| 7 | # Should-stop: |
| 8 | # Default-Start: S |
| 9 | # Default-Stop: |
| 10 | # Short-Description: Process /etc/modules. |
| 11 | # Description: Load the modules listed in /etc/modules. |
| 12 | ### END INIT INFO |
| 13 | |
| 14 | LOAD_MODULE=modprobe |
| 15 | [ -f /proc/modules ] || exit 0 |
| 16 | [ -f /etc/modules ] || [ -d /etc/modules-load.d ] || exit 0 |
| 17 | [ -e /sbin/modprobe ] || LOAD_MODULE=insmod |
| 18 | |
| 19 | if [ ! -f /lib/modules/`uname -r`/modules.dep ]; then |
| 20 | [ "$VERBOSE" != no ] && echo "Calculating module dependencies ..." |
| 21 | depmod -Ae |
| 22 | fi |
| 23 | |
| 24 | loaded_modules=" " |
| 25 | |
| 26 | process_file() { |
| 27 | file=$1 |
| 28 | |
| 29 | (cat $file; echo; ) | |
| 30 | while read module args |
| 31 | do |
| 32 | case "$module" in |
| 33 | \#*|"") continue ;; |
| 34 | esac |
| 35 | [ -n "$(echo $loaded_modules | grep " $module ")" ] && continue |
| 36 | [ "$VERBOSE" != no ] && echo -n "$module " |
| 37 | eval "$LOAD_MODULE $module $args >/dev/null 2>&1" |
| 38 | loaded_modules="${loaded_modules}${module} " |
| 39 | done |
| 40 | } |
| 41 | |
| 42 | [ "$VERBOSE" != no ] && echo -n "Loading modules: " |
| 43 | [ -f /etc/modules ] && process_file /etc/modules |
| 44 | |
| 45 | [ -d /etc/modules-load.d ] || exit 0 |
| 46 | |
| 47 | for f in /etc/modules-load.d/*.conf; do |
| 48 | process_file $f |
| 49 | done |
| 50 | [ "$VERBOSE" != no ] && echo |
| 51 | |
| 52 | exit 0 |