1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.5 2005-07-03 21:34:35 niro Exp $ |
# $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 |
source /etc/sysconfig/rc |
5 |
source $rc_functions |
source $rc_functions |
10 |
# source kernel config if exists |
# source kernel config if exists |
11 |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
12 |
|
|
13 |
# some needed functions functions |
# 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() { |
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 |
/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 |
# not provided by sysfs but needed |
91 |
ln -snf /proc/self/fd /dev/fd |
ln -snf /proc/self/fd /dev/fd |
92 |
ln -snf fd/0 /dev/stdin |
ln -snf fd/0 /dev/stdin |
93 |
ln -snf fd/1 /dev/stdout |
ln -snf fd/1 /dev/stdout |
94 |
ln -snf fd/2 /dev/stderr |
ln -snf fd/2 /dev/stderr |
95 |
ln -snf /proc/kcore /dev/core |
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
96 |
ln -snf /proc/asound/oss/sndstat /dev/sndstat |
|
|
|
|
97 |
# create problematic directories |
# create problematic directories |
98 |
mkdir -p /dev/{pts,shm} |
mkdir -p /dev/{pts,shm} |
99 |
|
) |
100 |
# same as /dev/.devfsd |
evaluate_retval |
|
touch /dev/.udev |
|
|
|
|
|
return 0 |
|
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 |
trap "" INT QUIT TSTP |
125 |
|
|
126 |
[ "$1" != "" ] && runlevel=$1 |
[ "$1" != "" ] && runlevel=$1 |
208 |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
209 |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
210 |
then |
then |
211 |
echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." |
echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
212 |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
213 |
evaluate_retval |
evaluate_retval |
214 |
fi |
fi |
215 |
|
|
216 |
# now load udev |
# other eeded device nodes with udev |
217 |
populate_udev |
seed_dev |
|
|
|
|
# if hotplug support exists in the kernel use it to manage udev |
|
|
if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." |
|
218 |
|
|
219 |
elif [ -e /proc/sys/kernel/hotplug ] |
if [ -e /proc/sys/kernel/hotplug ] |
220 |
then |
then |
221 |
echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." |
if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] |
222 |
echo "/sbin/udev" > /proc/sys/kernel/hotplug |
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 |
else |
241 |
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
242 |
|
print_status failure |
243 |
fi |
fi |
244 |
|
|
245 |
|
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
246 |
|
/sbin/udevd --daemon |
247 |
evaluate_retval |
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 |
fi |
261 |
|
|
262 |
## load devpts ## |
## load devpts ## |