blob: a78adf5729b3add5783af91b12ad0477cfea7ede [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/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
14LOAD_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
19if [ ! -f /lib/modules/`uname -r`/modules.dep ]; then
20 [ "$VERBOSE" != no ] && echo "Calculating module dependencies ..."
21 depmod -Ae
22fi
23
24loaded_modules=" "
25
26process_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
47for f in /etc/modules-load.d/*.conf; do
48 process_file $f
49done
50[ "$VERBOSE" != no ] && echo
51
52exit 0