aboutsummaryrefslogtreecommitdiffstats
path: root/mandriva/rc.modules
blob: e5f7e01b67316f5b1281ea1c30d6a6c21eb7380d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# (c) Mandriva, Chmouel Boudjnah <chmouel@mandriva.com>
# $Id$
# description: launch modules specified in /etc/modules inspired by a
# Debian idea.

MODULES=/etc/modprobe.preload
MODULES_D=$MODULES.d

# hardcoded from /etc/init.d/functions (to be faster and dash compliant)
strstr() {
  [ "${1#*$2*}" = "$1" ] && return 1
  return 0
}

cmdline=$(cat /proc/cmdline)
if strstr "$cmdline" modprobedebug; then
    MODPROBE_OPTIONS="-v"
    export MODPROBE_OPTIONS
    gprintf "Pre-loading modules\n"
fi

echo_modules() {
    # Loop over every line
    while read module args
    do
	case "$module" in
	    \#*|"") continue ;;
	esac
	echo $module
    done
}

TOLOAD=""
for f in $MODULES $MODULES_D/*; do
    [ -f $f ] || continue
    NEW=$( (cat $f; echo) | echo_modules )
    [ -n "$NEW" ] && TOLOAD="$TOLOAD $NEW"
done

if [ -n "$TOLOAD" ]; then
  logger -t $0 "Loading modules:"$TOLOAD
  /sbin/modprobe -a $TOLOAD 2>/dev/null
fi