Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download)
Mon Dec 13 22:52:07 2004 UTC (19 years, 5 months ago) by niro
Original Path: branches/unlabeled-1.1.1/magellan-initscripts/sbin/modules-update
File size: 4267 byte(s)
imported.

1 niro 2 #!/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 Megallan 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 /sbin/functions.sh
30     source /etc/init.d/functions
31    
32     KERNEL_2_5="no"
33    
34     #if [ "$(get_KV)" -ge "$(KV_to_int '2.5.48')" ]
35     #then
36     # KERNEL_2_5="yes"
37     #fi
38    
39     #needed for kernel 2.6
40     if [ "$(kernel_major_version)" == "2.6" ]
41     then
42     KERNEL_2_5="yes"
43     fi
44    
45    
46     set -e
47    
48     # Reset the sorting order since we depend on it
49     export LC_COLLATE="C"
50    
51     depdir() {
52     dep="`egrep '[[:space:]]*depfile' ${CFGFILE} | tail -n 1 | sed -e 's/depfile=//' -e 's,/[^/]*$,,'`"
53     if [ -z "${dep}" ]
54     then
55     dep="/lib/modules/$(uname -r)"
56     fi
57    
58     echo "${dep}"
59     }
60    
61     CFGFILES="${CFGFILE}"
62    
63     if [ "${KERNEL_2_5}" = "yes" ]
64     then
65     CFGFILES="${CFGFILES} ${CFGFILE2} ${CFGFILE4}"
66     fi
67    
68     for x in ${CFGFILES}
69     do
70     if [ -f "${x}" ]
71     then
72     if ! sed -ne 1p "${x}" | egrep -q "^${HEADER}"
73     then
74     echo "Error: the current ${x} is not automatically generated."
75    
76     if [ "$1" != "force" ]
77     then
78     echo "Use \"modules-update force\" to force (re)generation."
79     exit 1
80     else
81     echo "force specified, (re)generating file anyway."
82     fi
83     fi
84     fi
85     done
86    
87     if [ 0 -ne "`id -u`" ]
88     then
89     echo "You have to be root to do this."
90     exit 2
91     fi
92    
93     if [ -e "${CFGFILE}" ]
94     then
95     cp -f "${CFGFILE}" "${CFGFILE}".old
96     fi
97     if [ "${KERNEL_2_5}" = "yes" ]
98     then
99     if [ -e "${CFGFILE2}" ]
100     then
101     cp -f "${CFGFILE2}" "${CFGFILE2}".old
102     fi
103     if [ -e "${CFGFILE4}" ]
104     then
105     cp -f "${CFGFILE4}" "${CFGFILE4}".old
106     fi
107     fi
108    
109    
110     echo "${HEADER}" > "${TMPFILE}"
111     cat <<EOF >> "${TMPFILE}"
112     #
113     # Please do not edit this file directly. If you want to change or add
114     # anything please take a look at the files in ${MODDIR} and read
115     # the manpage for modules-update.
116     #
117     EOF
118     if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "yes" ]
119     then
120     sed -e "s:the files in ${MODDIR}:${CFGFILE}:" \
121     "${TMPFILE}" > "${TMPFILE2}"
122    
123     if [ -f "${CFGFILE3}" ]
124     then
125     sed -e "s:the files in ${MODDIR}:${CFGFILE3}:" \
126     "${TMPFILE}" > "${TMPFILE4}"
127     fi
128     fi
129    
130     for cfg in "${MODDIR}"/* "${CONF}"
131     do
132     [ -d "${cfg}" ] && continue
133    
134     [ ! -r "${cfg}" ] && continue
135    
136     [ -n "`echo "${cfg}" | awk '!/~$|\.bak$/ { print $0 }'`" ] || continue
137    
138     echo "### modules-update: start processing ${cfg}" >> "${TMPFILE}"
139    
140     if [ -x ${cfg} ]
141     then
142     # $cfg can be executable; nice touch, Wichert! :)
143     "${cfg}" >> "${TMPFILE}"
144     else
145     cat "${cfg}" >> "${TMPFILE}"
146     fi
147    
148     echo >> "${TMPFILE}"
149     echo "### modules-update: end processing ${cfg}" >> "${TMPFILE}"
150     echo >> "${TMPFILE}"
151     done
152    
153     mv -f "${TMPFILE}" "${CFGFILE}"
154    
155     if [ -x /sbin/generate-modprobe.conf -a "${KERNEL_2_5}" = "yes" ]
156     then
157     if /sbin/generate-modprobe.conf >> "${TMPFILE2}" 2> /dev/null
158     then
159     mv -f "${TMPFILE2}" "${CFGFILE2}"
160     else
161     echo "Warning: could not generate ${CFGFILE2}!"
162     rm -f "${TMPFILE2}"
163     fi
164    
165     if [ -f "${CFGFILE3}" ]
166     then
167     gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' "${CFGFILE3}" > "${TMPFILE3}"
168    
169     export TESTING_MODPROBE_CONF="${TMPFILE3}"
170     if /sbin/generate-modprobe.conf >> "${TMPFILE4}" 2> /dev/null
171     then
172     mv -f "${TMPFILE4}" "${CFGFILE4}"
173    
174     echo >> "${CFGFILE4}"
175     echo "include /etc/modprobe.conf" >> "${CFGFILE4}"
176     else
177     echo "Warning: could not generate ${CFGFILE4}!"
178     rm -f "${TMPFILE4}"
179     fi
180     rm -f "${TMPFILE3}"
181     fi
182     fi
183    
184     # We also call depmod here to stop insmod from complaining that modules.conf
185     # is more recent then modules.dep
186     #
187     if [ -d "`depdir`" -a -f /proc/modules ]
188     then
189     depmod -a
190     fi
191    
192    
193     # vim:ts=4

Properties

Name Value
svn:executable *