/[vps]/baselayout-vserver/trunk/init.d/modules
Gentoo

Contents of /baselayout-vserver/trunk/init.d/modules

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sat Sep 3 16:10:27 2005 UTC (9 years, 3 months ago) by hollow
File size: 2956 byte(s)
import initial baselayout sources (1.12.0_pre8)
1 #!/sbin/runscript
2 # Copyright 1999-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 depend() {
6 need checkroot hostname
7 use isapnp
8 }
9
10 load_modules() {
11 local x=
12 local i=0
13 local retval=0
14 local modules=
15 local modargs=
16 local modcount=0
17 local config="$1"
18
19 [[ -z ${config} || ! -r ${config} ]] && return 0
20
21 # Loop over every line in $config
22 eval $(awk '
23 BEGIN {
24 COUNT = 0 # Make sure COUNT is set
25 }
26
27 $0 !~ /(^[[:space:]]*(#|$))/ {
28 if (MODULES == "")
29 MODULES = $1
30 else
31 MODULES = MODULES " " $1
32
33 # Not the greatest method to remove $1 from $0, but it works
34 sub(/^[[:space:]]*[^[:space:]]*[[:space:]]*/, "")
35 # Trim trailing comments on the line
36 sub(/#.*$/, "")
37 ARGS[COUNT] = $0
38 COUNT++
39 }
40
41 END {
42 # 'eval' will make sure these are set to proper bash variables
43 print "modcount=" COUNT
44 print "modules=\"" MODULES "\""
45 for (x = 0;x < COUNT;x++)
46 print "modargs[" x "]=\"" ARGS[x] "\""
47 }
48 ' "${config}")
49
50 if [[ ${modcount} -gt 0 ]]; then
51 einfo "Using ${config} as config:"
52
53 for x in ${modules}; do
54 ebegin " Loading module ${x}"
55 modprobe -q ${x} ${modargs[${i}]} &>/dev/null
56 retval=$?
57 eend ${retval} " Failed to load ${x}"
58
59 i=$((i+1))
60 [[ ${retval} -eq 0 ]] || modcount=$((modcount-1))
61 done
62
63 einfo "Autoloaded ${modcount} module(s)"
64 fi
65
66 return 0
67 }
68
69 start() {
70 local KV=$(uname -r)
71 local KV_MAJOR=$(KV_major "${KV}")
72 local KV_MINOR=$(KV_minor "${KV}")
73 local KV_MICRO=$(KV_micro "${KV}")
74
75 # Should not fail if kernel do not have module
76 # support compiled in ...
77 [[ -f /proc/modules ]] || return 0
78
79 # Make sure depmod from modutils do not whine, but do not bother if
80 # we are on a 2.6 kernel without modprobe.old
81 if [[ -z "${CDBOOT}" ]] && [[ ! -e /etc/modules.conf ]] && \
82 [[ $(get_KV) -lt $(KV_to_int '2.5.48') || -x /sbin/modprobe.old ]]
83 then
84 echo '### This file is automatically generated by modules-update' \
85 > /etc/modules.conf 2>/dev/null
86 [[ ! -f /etc/modules.conf ]] && \
87 ewarn "Cannot update /etc/modules.conf!"
88 fi
89
90 # Only do this if we have modules.conf or a 2.6 kernel
91 if [[ -z "${CDBOOT}" ]] && \
92 [[ -f /etc/modules.conf || $(get_KV) -ge $(KV_to_int '2.5.48') ]]
93 then
94 /sbin/modules-update
95 fi
96
97 local autoload=""
98 if [[ -f /etc/modules.autoload && ! -L /etc/modules.autoload ]]; then
99 autoload=/etc/modules.autoload
100 else
101 local x
102 for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do
103 if [[ -f /etc/modules.autoload.d/kernel-"${x}" ]] ; then
104 autoload="/etc/modules.autoload.d/kernel-${x}"
105 break
106 fi
107 done
108 fi
109 [[ -n ${autoload} ]] && load_modules "${autoload}"
110
111 #
112 # Just in case a sysadmin prefers generic symbolic links in
113 # /lib/modules/boot for boot time modules we will load these modules
114 #
115 [[ -n $(modprobe -l -t boot) ]] && modprobe -a -t boot \* &>/dev/null
116
117 # Above test clobbers the return
118 return 0
119 }
120
121
122 # vim:ts=4

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20