Magellan Linux

Contents of /tags/init-0_5_2/sbin/modules-update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 105 - (show annotations) (download)
Fri Jul 1 18:09:42 2005 UTC (18 years, 10 months ago) by niro
Original Path: trunk/magellan-initscripts/sbin/modules-update
File size: 4158 byte(s)
removed whitespaces and typos

1 #!/bin/bash
2 #
3 # This is the modules-update script for Debian GNU/Linux.
4 # Written by Wichert Akkerman <wakkerma@debian.org>
5 # Copyright (C) 1998, 1999 Software in the Public Interest
6
7 # Modifications by Daniel Robbins <drobbins@gentoo.org>, Gentoo Technologies, Inc.
8 # 02 Sep 2001 -- Removed "arch" stuff since I see no reason to have support for varying
9 # CPU architectures on a single system.
10
11 # More modifications by Niels Rogalla <niro@magellan-linux.net> for Magellan-Linux
12 # Hacked some entries to fit into Magellan:
13 # functions.sh & kernel-2.5 stuff not needed
14
15 # 06.09.2004 Added kernel 2.6 stuff <niro@magellan-linux.net>
16
17 CFGFILE="/etc/modules.conf"
18 TMPFILE="${CFGFILE}.$$"
19 CFGFILE2="/etc/modprobe.conf"
20 TMPFILE2="${CFGFILE2}.$$"
21 CFGFILE3="/etc/modules.devfs"
22 TMPFILE3="${CFGFILE3}.$$"
23 CFGFILE4="/etc/modprobe.devfs"
24 TMPFILE4="${CFGFILE4}.$$"
25 MODDIR="/etc/modules.d"
26 ARCHDIR="${MODDIR}/arch"
27 HEADER="### This file is automatically generated by modules-update"
28
29 source /etc/init.d/functions
30
31 KERNEL_2_5="no"
32
33 # needed for kernel 2.6
34 if [ "$(kernel_major_version)" == "2.6" ]
35 then
36 KERNEL_2_5="yes"
37 fi
38
39
40 set -e
41
42 # Reset the sorting order since we depend on it
43 export LC_COLLATE="C"
44
45 depdir() {
46 dep="`egrep '[[:space:]]*depfile' ${CFGFILE} | tail -n 1 | sed -e 's/depfile=//' -e 's,/[^/]*$,,'`"
47 if [ -z "${dep}" ]
48 then
49 dep="/lib/modules/$(uname -r)"
50 fi
51
52 echo "${dep}"
53 }
54
55 CFGFILES="${CFGFILE}"
56
57 if [ "${KERNEL_2_5}" = "yes" ]
58 then
59 CFGFILES="${CFGFILES} ${CFGFILE2} ${CFGFILE4}"
60 fi
61
62 for x in ${CFGFILES}
63 do
64 if [ -f "${x}" ]
65 then
66 if ! sed -ne 1p "${x}" | egrep -q "^${HEADER}"
67 then
68 echo "Error: the current ${x} is not automatically generated."
69
70 if [ "$1" != "force" ]
71 then
72 echo "Use \"modules-update force\" to force (re)generation."
73 exit 1
74 else
75 echo "force specified, (re)generating file anyway."
76 fi
77 fi
78 fi
79 done
80
81 if [ 0 -ne "`id -u`" ]
82 then
83 echo "You have to be root to do this."
84 exit 2
85 fi
86
87 if [ -e "${CFGFILE}" ]
88 then
89 cp -f "${CFGFILE}" "${CFGFILE}".old
90 fi
91 if [ "${KERNEL_2_5}" = "yes" ]
92 then
93 if [ -e "${CFGFILE2}" ]
94 then
95 cp -f "${CFGFILE2}" "${CFGFILE2}".old
96 fi
97 if [ -e "${CFGFILE4}" ]
98 then
99 cp -f "${CFGFILE4}" "${CFGFILE4}".old
100 fi
101 fi
102
103
104 echo "${HEADER}" > "${TMPFILE}"
105 cat <<EOF >> "${TMPFILE}"
106 #
107 # Please do not edit this file directly. If you want to change or add
108 # anything please take a look at the files in ${MODDIR} and read
109 # the manpage for modules-update.
110 #
111 EOF
112 if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "yes" ]
113 then
114 sed -e "s:the files in ${MODDIR}:${CFGFILE}:" \
115 "${TMPFILE}" > "${TMPFILE2}"
116
117 if [ -f "${CFGFILE3}" ]
118 then
119 sed -e "s:the files in ${MODDIR}:${CFGFILE3}:" \
120 "${TMPFILE}" > "${TMPFILE4}"
121 fi
122 fi
123
124 for cfg in "${MODDIR}"/* "${CONF}"
125 do
126 [ -d "${cfg}" ] && continue
127
128 [ ! -r "${cfg}" ] && continue
129
130 [ -n "`echo "${cfg}" | awk '!/~$|\.bak$/ { print $0 }'`" ] || continue
131
132 echo "### modules-update: start processing ${cfg}" >> "${TMPFILE}"
133
134 if [ -x ${cfg} ]
135 then
136 # $cfg can be executable; nice touch, Wichert! :)
137 "${cfg}" >> "${TMPFILE}"
138 else
139 cat "${cfg}" >> "${TMPFILE}"
140 fi
141
142 echo >> "${TMPFILE}"
143 echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}"
144 echo >> "${TMPFILE}"
145 done
146
147 mv -f "${TMPFILE}" "${CFGFILE}"
148
149 if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "yes" ]
150 then
151 if /sbin/generate-modprobe.conf >> "${TMPFILE2}" 2> /dev/null
152 then
153 mv -f "${TMPFILE2}" "${CFGFILE2}"
154 else
155 echo "Warning: could not generate ${CFGFILE2}!"
156 rm -f "${TMPFILE2}"
157 fi
158
159 if [ -f "${CFGFILE3}" ]
160 then
161 gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" > "${TMPFILE3}"
162
163 export TESTING_MODPROBE_CONF="${TMPFILE3}"
164 if /sbin/generate-modprobe.conf >> "${TMPFILE4}" 2> /dev/null
165 then
166 mv -f "${TMPFILE4}" "${CFGFILE4}"
167
168 echo >> "${CFGFILE4}"
169 echo "include /etc/modprobe.conf" >> "${CFGFILE4}"
170 else
171 echo "Warning: could not generate ${CFGFILE4}!"
172 rm -f "${TMPFILE4}"
173 fi
174 rm -f "${TMPFILE3}"
175 fi
176 fi
177
178 # We also call depmod here to stop insmod from complaining that modules.conf
179 # is more recent then modules.dep
180 #
181 if [ -d "`depdir`" -a -f /proc/modules ]
182 then
183 depmod -a
184 fi
185
186
187 # vim:ts=4

Properties

Name Value
svn:executable *