blob: 28fe6f92d77f20086f1d974dcddd4bb48e7f8653 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
Andrew Geissler09209ee2020-12-13 08:44:15 -060017# Test if modules.dep exists and has a size greater than zero
18if [ ! -s /lib/modules/`uname -r`/modules.dep ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 [ "$VERBOSE" != no ] && echo "Calculating module dependencies ..."
Andrew Geisslerd1e89492021-02-12 15:35:20 -060020 depmod -a
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021fi
22
Andrew Geissler09209ee2020-12-13 08:44:15 -060023[ -f /etc/modules ] || [ -d /etc/modules-load.d ] || exit 0
24[ -e /sbin/modprobe ] || LOAD_MODULE=insmod
25
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026loaded_modules=" "
27
28process_file() {
29 file=$1
30
31 (cat $file; echo; ) |
32 while read module args
33 do
34 case "$module" in
35 \#*|"") continue ;;
36 esac
37 [ -n "$(echo $loaded_modules | grep " $module ")" ] && continue
38 [ "$VERBOSE" != no ] && echo -n "$module "
39 eval "$LOAD_MODULE $module $args >/dev/null 2>&1"
40 loaded_modules="${loaded_modules}${module} "
41 done
42}
43
44[ "$VERBOSE" != no ] && echo -n "Loading modules: "
45[ -f /etc/modules ] && process_file /etc/modules
46
47[ -d /etc/modules-load.d ] || exit 0
48
49for f in /etc/modules-load.d/*.conf; do
50 process_file $f
51done
52[ "$VERBOSE" != no ] && echo
53
54exit 0