Contents of /trunk/magellan-initscripts/rc/rc
Parent Directory | Revision Log
Revision 318 -
(show annotations)
(download)
Tue Jan 3 18:03:21 2006 UTC (18 years, 8 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 10463 byte(s)
Tue Jan 3 18:03:21 2006 UTC (18 years, 8 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 10463 byte(s)
added >= udev-079 support for 2.6.15 kernels
1 | #!/bin/bash |
2 | # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.6 2006-01-03 18:03:21 niro Exp $ |
3 | |
4 | source /etc/sysconfig/rc |
5 | source $rc_functions |
6 | |
7 | # get mage version |
8 | MAGEVER="$(< /etc/mageversion)" |
9 | |
10 | # source kernel config if exists |
11 | [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
12 | |
13 | # this works only for 2.6.15 kernels and greater |
14 | trigger_events() |
15 | { |
16 | local list="" |
17 | local i |
18 | local first |
19 | local last |
20 | local default |
21 | |
22 | # if you want real hotplug (with all modules being loaded for all |
23 | # devices in the system), uncomment out the next line. |
24 | #list="$list $(echo /sys/bus/*/devices/*/uevent)" |
25 | list="${list} $(echo /sys/class/*/*/uevent)" |
26 | list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)" |
27 | for i in ${list} |
28 | do |
29 | case "${i}" in |
30 | */device/uevent) |
31 | # skip followed device symlinks |
32 | continue |
33 | ;; |
34 | */class/mem/*|*/class/tty/*) |
35 | first="${first} ${i}" |
36 | ;; |
37 | */block/md*) |
38 | last="${last} ${i}" |
39 | ;; |
40 | */*) |
41 | default="${default} ${i}" |
42 | ;; |
43 | esac |
44 | done |
45 | |
46 | # trigger the sorted events |
47 | for i in ${first} ${default} ${last} |
48 | do |
49 | echo "add" > "${i}" |
50 | done |
51 | } |
52 | |
53 | populate_udev() { |
54 | local loop |
55 | |
56 | # populate /dev with devices already found by the kernel |
57 | if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] |
58 | then |
59 | echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
60 | trigger_events |
61 | evaluate_retval |
62 | else |
63 | echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." |
64 | /sbin/udevstart |
65 | evaluate_retval |
66 | fi |
67 | |
68 | # loop until everything is finished |
69 | # there's gotta be a better way... |
70 | echo -e ${COLOREDSTAR}" Letting udev process events ..." |
71 | loop=0 |
72 | while test -d /dev/.udev/queue |
73 | do |
74 | sleep 0.1; |
75 | test "${loop}" -gt 300 && break |
76 | loop=$((${loop} + 1)) |
77 | done |
78 | evaluate_retval |
79 | |
80 | return 0 |
81 | } |
82 | |
83 | seed_dev() { |
84 | # seed /dev with some things that we know we need |
85 | echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." |
86 | ( |
87 | # copy over any persistant things |
88 | cp --preserve=all --recursive --update /lib/udev/devices/* /dev |
89 | |
90 | # not provided by sysfs but needed |
91 | ln -snf /proc/self/fd /dev/fd |
92 | ln -snf fd/0 /dev/stdin |
93 | ln -snf fd/1 /dev/stdout |
94 | ln -snf fd/2 /dev/stderr |
95 | [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
96 | |
97 | # create problematic directories |
98 | mkdir -p /dev/{pts,shm} |
99 | ) |
100 | evaluate_retval |
101 | } |
102 | |
103 | # # some needed functions functions |
104 | # populate_udev() { |
105 | # /sbin/udevstart |
106 | # |
107 | # # not provided by sysfs but needed |
108 | # ln -snf /proc/self/fd /dev/fd |
109 | # ln -snf fd/0 /dev/stdin |
110 | # ln -snf fd/1 /dev/stdout |
111 | # ln -snf fd/2 /dev/stderr |
112 | # ln -snf /proc/kcore /dev/core |
113 | # ln -snf /proc/asound/oss/sndstat /dev/sndstat |
114 | # |
115 | # # create problematic directories |
116 | # mkdir -p /dev/{pts,shm} |
117 | # |
118 | # # same as /dev/.devfsd |
119 | # touch /dev/.udev |
120 | # |
121 | # return 0 |
122 | # } |
123 | |
124 | trap "" INT QUIT TSTP |
125 | |
126 | [ "$1" != "" ] && runlevel=$1 |
127 | |
128 | if [[ $runlevel = sysinit ]] |
129 | then |
130 | echo |
131 | echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
132 | echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" |
133 | echo |
134 | |
135 | # mount proc filesystem, needed for bootsplash; |
136 | # no use of '/etc/rc.d/init.d/mountproc' anymore |
137 | if [ ! -e /proc/mounts ] |
138 | then |
139 | echo -e ${COLOREDSTAR}"Mounting proc file system ..." |
140 | mount -n /proc |
141 | evaluate_retval |
142 | fi |
143 | |
144 | # set default verbose level for kernel messages |
145 | [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
146 | echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
147 | |
148 | # mount sys file system before udev or devfs (kernel-2.6) |
149 | if [[ $(kernel_major_version) = 2.6 ]] |
150 | then |
151 | if [ -d /sys ] |
152 | then |
153 | echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
154 | mount -n -t sysfs sysfs /sys |
155 | evaluate_retval |
156 | else |
157 | echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
158 | echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
159 | echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
160 | fi |
161 | fi |
162 | |
163 | ## load devfs ## |
164 | # load devfs only with a 2.4 kernel or its really wanted with a 2.6 |
165 | if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]] |
166 | then |
167 | # start devfsd daemon, needed for bootsplash; |
168 | # no use of '/etc/rc.d/init.d/devfs' anymore |
169 | # check if devfs was mounted by the kernel, |
170 | # if not mount it (mbuild_livecd needs this one) |
171 | if [ ! -e /dev/.devfsd ] |
172 | then |
173 | echo -e ${COLOREDSTAR}"Mounting devfs file system ..." |
174 | mount -n -t devfs devfs /dev |
175 | evaluate_retval |
176 | fi |
177 | |
178 | if [ -e /dev/.devfsd ] |
179 | then |
180 | echo -e ${COLOREDSTAR}"Starting devfsd ..." |
181 | ## directory /lib/dev-state !must! exists ## |
182 | /sbin/devfsd /dev &> /dev/null |
183 | evaluate_retval |
184 | else |
185 | echo -e ${COLRED}"No devfs filesystem found ..." |
186 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem." |
187 | echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux." |
188 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
189 | echo |
190 | echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..." |
191 | read |
192 | $rc_base/init.d/halt |
193 | fi |
194 | fi |
195 | |
196 | #### load udev #### |
197 | # load udev only with a 2.6 kernel |
198 | if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
199 | then |
200 | # create a ramdisk for populating udev |
201 | echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
202 | # tmpfs was suggested by Greg Kroah-Hartman |
203 | # many video drivers needed exec access |
204 | mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 |
205 | evaluate_retval |
206 | |
207 | # if a device tarball exists load it and if it is activated |
208 | echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
209 | if [[ ${RC_DEVICE_TARBALL} = yes ]] |
210 | then |
211 | echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
212 | tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
213 | evaluate_retval |
214 | fi |
215 | |
216 | # other eeded device nodes with udev |
217 | seed_dev |
218 | |
219 | if [ -e /proc/sys/kernel/hotplug ] |
220 | then |
221 | if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] |
222 | then |
223 | echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
224 | echo "" > /proc/sys/kernel/hotplug |
225 | evaluate_retval |
226 | elif [[ $(udev_version) -ge "48" ]] |
227 | then |
228 | echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." |
229 | echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
230 | evaluate_retval |
231 | elif [[ -x /sbin/hotplug ]] |
232 | then |
233 | echo -e ${COLOREDSTAR}" Using /sbin/hotplug as hotplug agent ..." |
234 | print_status success |
235 | else |
236 | echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." |
237 | echo "/sbin/udev" > /proc/sys/kernel/hotplug |
238 | evaluate_retval |
239 | fi |
240 | else |
241 | echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
242 | print_status failure |
243 | fi |
244 | |
245 | echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
246 | /sbin/udevd --daemon |
247 | evaluate_retval |
248 | |
249 | populate_udev |
250 | |
251 | # create nodes that udev can't |
252 | echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
253 | [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
254 | [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
255 | [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
256 | print_status success |
257 | |
258 | # same thing as /dev/.devfsd |
259 | touch /dev/.udev |
260 | fi |
261 | |
262 | ## load devpts ## |
263 | # devfs/udev with 2.6 has no ptys, so devpts is also needed |
264 | if [[ $(kernel_major_version) = 2.6 ]] |
265 | then |
266 | # check if we really have devpts support |
267 | if kernel_supports_fs devpts |
268 | then |
269 | # /dev/pts maybe not exists. |
270 | # We only create this directory only if devfs was mounted, |
271 | # or it will fail as / is still mounted readonly |
272 | # udev has this dir already, only a sanity check for devfs |
273 | if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
274 | then |
275 | mkdir -p /dev/pts &> /dev/null || \ |
276 | echo "Could not create /dev/pts !" |
277 | fi |
278 | |
279 | # now mount devpts |
280 | if [ -d /dev/pts ] |
281 | then |
282 | echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
283 | mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
284 | evaluate_retval |
285 | fi |
286 | else |
287 | # devpts is not supported, give a warning |
288 | echo -e ${COLRED}"No devpts filesystem found ..." |
289 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
290 | echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," |
291 | echo -e ${COLYELLOW}"or no pty's are available." |
292 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
293 | echo |
294 | echo -e ${COLYELLOW}"Press any key to continue ..." |
295 | read |
296 | fi |
297 | fi |
298 | |
299 | ### services state dir ### |
300 | echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
301 | mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k |
302 | evaluate_retval |
303 | |
304 | # load bootsplash |
305 | splash "rc_init" "${runlevel}" |
306 | fi |
307 | |
308 | |
309 | if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] |
310 | then |
311 | # load bootsplash |
312 | splash "rc_init" "${runlevel}" |
313 | |
314 | # if requested save devices to a device tarball before halt |
315 | # only for kernels >=2.6 *and* udev |
316 | # make shure that udev is mounted but *not* devfs --> /dev/.devfsd |
317 | if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
318 | [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
319 | then |
320 | echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
321 | ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
322 | mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
323 | evaluate_retval |
324 | fi |
325 | fi |
326 | |
327 | |
328 | if [ "$runlevel" = "" ] |
329 | then |
330 | echo "Usage: $0 <runlevel>" >&2 |
331 | exit 1 |
332 | fi |
333 | |
334 | |
335 | previous=$PREVLEVEL |
336 | [ "$previous" = "" ] && previous=N |
337 | |
338 | if [ ! -d $rc_base/rc$runlevel.d ] |
339 | then |
340 | echo "$rc_base/rc$runlevel.d does not exist" |
341 | exit 1 |
342 | fi |
343 | |
344 | if [ "$previous" != "N" ] |
345 | then |
346 | for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null) |
347 | do |
348 | |
349 | check_script_status |
350 | |
351 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} |
352 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
353 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix |
354 | |
355 | if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ] |
356 | then |
357 | if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] |
358 | then |
359 | $WARNING |
360 | echo "$i can't be executed because it was" |
361 | echo "not started in the previous runlevel ($previous)" |
362 | $NORMAL |
363 | continue |
364 | fi |
365 | fi |
366 | |
367 | $i stop |
368 | error_value=$? |
369 | |
370 | if [ "$error_value" != "0" ] |
371 | then |
372 | print_error_msg |
373 | fi |
374 | done |
375 | fi |
376 | |
377 | for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null) |
378 | do |
379 | if [ "$previous" != "N" ] |
380 | then |
381 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} |
382 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix |
383 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
384 | |
385 | [ -f $prev_start ] && [ ! -f $stop ] && continue |
386 | fi |
387 | |
388 | check_script_status |
389 | |
390 | $i start |
391 | error_value=$? |
392 | |
393 | if [ "$error_value" != "0" ] |
394 | then |
395 | print_error_msg |
396 | fi |
397 | done |
Properties
Name | Value |
---|---|
svn:executable | * |