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.12 2007-02-07 08:07:43 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 |
udev_version() |
14 |
populate_udev() { |
{ |
15 |
|
local version=0 |
16 |
|
|
17 |
|
if [[ -x /sbin/udev ]] |
18 |
|
then |
19 |
|
version=$(/sbin/udev -V) |
20 |
|
# We need it without a leading '0', else bash do the wrong thing |
21 |
|
version=${version##0} |
22 |
|
# Older udev's will print nothing |
23 |
|
[[ -z ${version} ]] && version=0 |
24 |
|
fi |
25 |
|
|
26 |
|
echo "${version}" |
27 |
|
} |
28 |
|
|
29 |
|
populate_udev() |
30 |
|
{ |
31 |
|
local opts |
32 |
|
|
33 |
|
# populate /dev with devices already found by the kernel |
34 |
|
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
35 |
|
then |
36 |
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
37 |
|
[[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev" |
38 |
|
/sbin/udevtrigger ${opts} |
39 |
|
evaluate_retval |
40 |
|
else |
41 |
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." |
42 |
/sbin/udevstart |
/sbin/udevstart |
43 |
|
evaluate_retval |
44 |
|
fi |
45 |
|
|
46 |
|
# loop until everything is finished |
47 |
|
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
48 |
|
/sbin/udevsettle --timeout=60 |
49 |
|
evaluate_retval |
50 |
|
|
51 |
|
return 0 |
52 |
|
} |
53 |
|
|
54 |
|
seed_dev() |
55 |
|
{ |
56 |
|
# seed /dev with some things that we know we need |
57 |
|
echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." |
58 |
|
( |
59 |
|
# copy over any persistant things |
60 |
|
if [[ -d /lib/udev/devices ]] |
61 |
|
then |
62 |
|
cp --preserve=all --recursive --update /lib/udev/devices/* /dev |
63 |
|
fi |
64 |
|
|
65 |
# not provided by sysfs but needed |
# not provided by sysfs but needed |
66 |
ln -snf /proc/self/fd /dev/fd |
ln -snf /proc/self/fd /dev/fd |
67 |
ln -snf fd/0 /dev/stdin |
ln -snf fd/0 /dev/stdin |
68 |
ln -snf fd/1 /dev/stdout |
ln -snf fd/1 /dev/stdout |
69 |
ln -snf fd/2 /dev/stderr |
ln -snf fd/2 /dev/stderr |
70 |
ln -snf /proc/kcore /dev/core |
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
71 |
ln -snf /proc/asound/oss/sndstat /dev/sndstat |
|
|
|
|
72 |
# create problematic directories |
# create problematic directories |
73 |
mkdir -p /dev/{pts,shm} |
mkdir -p /dev/{pts,shm} |
74 |
|
) |
75 |
# same as /dev/.devfsd |
evaluate_retval |
|
touch /dev/.udev |
|
|
|
|
|
return 0 |
|
76 |
} |
} |
77 |
|
|
78 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
83 |
then |
then |
84 |
echo |
echo |
85 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
86 |
echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" |
echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net" |
87 |
echo |
echo |
88 |
|
|
89 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
153 |
then |
then |
154 |
# create a ramdisk for populating udev |
# create a ramdisk for populating udev |
155 |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
|
# tmpfs was suggested by Greg Kroah-Hartman |
|
156 |
# many video drivers needed exec access |
# many video drivers needed exec access |
157 |
mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 |
fstype=ramfs |
158 |
|
# tmpfs was suggested by Greg Kroah-Hartman |
159 |
|
kernel_supports_fs tmpfs && fstype=tmpfs |
160 |
|
mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755 |
161 |
evaluate_retval |
evaluate_retval |
162 |
|
|
163 |
# if a device tarball exists load it and if it is activated |
# if a device tarball exists load it and if it is activated |
164 |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
165 |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
166 |
then |
then |
167 |
echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." |
echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
168 |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
169 |
evaluate_retval |
evaluate_retval |
170 |
fi |
fi |
171 |
|
|
172 |
# now load udev |
# other eeded device nodes with udev |
173 |
populate_udev |
seed_dev |
174 |
|
|
175 |
# if hotplug support exists in the kernel use it to manage udev |
if [ -e /proc/sys/kernel/hotplug ] |
|
if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] |
|
176 |
then |
then |
177 |
echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." |
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
178 |
|
then |
179 |
elif [ -e /proc/sys/kernel/hotplug ] |
echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
180 |
then |
echo "" > /proc/sys/kernel/hotplug |
181 |
echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." |
evaluate_retval |
182 |
echo "/sbin/udev" > /proc/sys/kernel/hotplug |
else |
183 |
|
echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." |
184 |
|
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
185 |
|
evaluate_retval |
186 |
|
fi |
187 |
else |
else |
188 |
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
189 |
|
print_status failure |
190 |
fi |
fi |
191 |
|
|
192 |
|
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
193 |
|
/sbin/udevd --daemon |
194 |
evaluate_retval |
evaluate_retval |
195 |
|
|
196 |
|
populate_udev |
197 |
|
|
198 |
|
# create nodes that udev can't |
199 |
|
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
200 |
|
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
201 |
|
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
202 |
|
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
203 |
|
print_status success |
204 |
|
|
205 |
|
# same thing as /dev/.devfsd |
206 |
|
touch /dev/.udev |
207 |
fi |
fi |
208 |
|
|
209 |
## load devpts ## |
## load devpts ## |