/[baselayout]/trunk/init.d.Linux/modules
Gentoo

Contents of /trunk/init.d.Linux/modules

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2763 - (show annotations) (download)
Tue Jul 10 19:09:41 2007 UTC (7 years, 1 month ago) by uberlord
File size: 2549 byte(s)
init scripts and their extra options can now have descriptions, #184327.
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 description="Loads a user defined list of kernel modules."
6
7 depend() {
8 need checkroot
9 use isapnp
10 }
11
12 load_modules() {
13 local modules=""
14 local config="$1"
15
16 [ -z "${config}" -o ! -r "${config}" ] && return 0
17
18 eval set -- $(sed -e 's:#.*::' -e '/^[[:space:]]*$/d' \
19 -e "s/'/'\\\\''/g" -e "s/^/'/g" -e "s/$/'/g" "${config}")
20 [ $# = 0 ] && return 0
21
22 einfo "Using ${config} as config:"
23 eindent
24
25 local x= cnt=0
26 for x in "$@" ; do
27 set -- ${x}
28 ebegin "Loading module $1"
29 eval modprobe -q "$@"
30 eend $? "Failed to load $1" && cnt=$((${cnt} + 1))
31 done
32
33 einfo "Autoloaded ${cnt} module(s)"
34
35 return 0
36 }
37
38 start() {
39 # Should not fail if kernel do not have module
40 # support compiled in ...
41 [ ! -f /proc/modules -o "${RC_SYS}" = "VPS" ] && return 0
42
43 local KV=$(uname -r)
44 local KV_MAJOR=${KV%%.*}
45 local x=${KV#*.}
46 local KV_MINOR=${x%%.*}
47 x=${KV#*.*.}
48 local KV_MICRO=${x%%-*}
49
50 # Make sure depmod from modutils do not whine, but do not bother if
51 # we are on a 2.6 kernel without modprobe.old
52 if [ -z "${CDBOOT}" -a ! -e /etc/modules.conf ] && \
53 [ $(KV_to_int "${KV}") -lt $(KV_to_int '2.5.48') -o -x /sbin/modprobe.old ]
54 then
55 echo '### This file is automatically generated by update-modules' \
56 > /etc/modules.conf 2>/dev/null
57 [ ! -f /etc/modules.conf ] && \
58 ewarn "Cannot update /etc/modules.conf!"
59 fi
60
61 # Only do this if we have modules.conf or a 2.6 kernel
62 if [ -z "${CDBOOT}" ] && \
63 [ -f /etc/modules.conf -o $(KV_to_int "${KV}") -ge $(KV_to_int '2.5.48') ]
64 then
65 /sbin/update-modules
66 fi
67
68 local auto=""
69 if [ -f /etc/modules.autoload -a ! -L /etc/modules.autoload ]; then
70 auto=/etc/modules.autoload
71 else
72 local x= f="/etc/modules.autoload.d/kernel"
73 for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do
74 if [ -f "${f}-${x}.${RC_SOFTLEVEL}" ] ; then
75 auto="${f}-${x}.${RC_SOFTLEVEL}"
76 break
77 fi
78 if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" -a -f "${f}-${x}.${RC_DEFAULTLEVEL}" ] ; then
79 auto="${f}-${x}.${RC_DEFAULTLEVEL}"
80 break
81 fi
82 if [ -f "${f}-${x}" ] ; then
83 auto="${f}-${x}"
84 break
85 fi
86 done
87 fi
88 [ -n "${auto}" ] && load_modules "${auto}"
89
90 #
91 # Just in case a sysadmin prefers generic symbolic links in
92 # /lib/modules/boot for boot time modules we will load these modules
93 #
94 [ -n "$(modprobe -l -t boot)" ] && modprobe -a -t boot \* 2>/dev/null
95
96 # Above test clobbers the return
97 return 0
98 }
99
100
101 # vim:ts=4

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20