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.17 2007-09-01 19:13:18 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 |
|
elif [[ -x /sbin/udevd ]] |
25 |
|
then |
26 |
|
version=$(/sbin/udevd --version) |
27 |
|
version=${version##0} |
28 |
|
[[ -z ${version} ]] && version=0 |
29 |
|
fi |
30 |
|
|
31 |
|
echo "${version}" |
32 |
|
} |
33 |
|
|
34 |
|
populate_udev() |
35 |
|
{ |
36 |
|
local opts |
37 |
|
|
38 |
|
# tell modprobe.sh to be verbose to $CONSOLE |
39 |
|
echo CONSOLE=${CONSOLE} > /dev/.udev_populate |
40 |
|
|
41 |
|
# populate /dev with devices already found by the kernel |
42 |
|
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
43 |
|
then |
44 |
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
45 |
|
[[ $(udev_version) -ge "96" ]] && [[ ${RC_COLDPLUG} != yes ]] && opts="--attr-match=dev" |
46 |
|
/sbin/udevtrigger ${opts} |
47 |
|
evaluate_retval |
48 |
|
else |
49 |
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." |
50 |
/sbin/udevstart |
/sbin/udevstart |
51 |
|
evaluate_retval |
52 |
|
fi |
53 |
|
|
54 |
|
# loop until everything is finished |
55 |
|
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
56 |
|
/sbin/udevsettle --timeout=60 |
57 |
|
evaluate_retval |
58 |
|
|
59 |
|
rm -f /dev/.udev_populate |
60 |
|
return 0 |
61 |
|
} |
62 |
|
|
63 |
|
seed_dev() |
64 |
|
{ |
65 |
|
# seed /dev with some things that we know we need |
66 |
|
echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." |
67 |
|
( |
68 |
|
[ ! -c /dev/console ] && mknod /dev/console c 5 1 |
69 |
|
[ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1 |
70 |
|
[ ! -c /dev/null ] && mknod /dev/null c 1 3 |
71 |
|
|
72 |
|
# copy over any persistant things |
73 |
|
if [[ -d /lib/udev/devices ]] |
74 |
|
then |
75 |
|
cp --preserve=all --recursive --update /lib/udev/devices/* /dev 2>/dev/null |
76 |
|
fi |
77 |
|
|
78 |
# not provided by sysfs but needed |
# not provided by sysfs but needed |
79 |
ln -snf /proc/self/fd /dev/fd |
ln -snf /proc/self/fd /dev/fd |
80 |
ln -snf fd/0 /dev/stdin |
ln -snf fd/0 /dev/stdin |
81 |
ln -snf fd/1 /dev/stdout |
ln -snf fd/1 /dev/stdout |
82 |
ln -snf fd/2 /dev/stderr |
ln -snf fd/2 /dev/stderr |
83 |
ln -snf /proc/kcore /dev/core |
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
84 |
ln -snf /proc/asound/oss/sndstat /dev/sndstat |
|
|
|
|
85 |
# create problematic directories |
# create problematic directories |
86 |
mkdir -p /dev/{pts,shm} |
mkdir -p /dev/{pts,shm} |
87 |
|
) |
88 |
# same as /dev/.devfsd |
evaluate_retval |
|
touch /dev/.udev |
|
|
|
|
|
return 0 |
|
89 |
} |
} |
90 |
|
|
91 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
96 |
then |
then |
97 |
echo |
echo |
98 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
99 |
echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" |
echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net" |
100 |
echo |
echo |
101 |
|
|
102 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
164 |
# load udev only with a 2.6 kernel |
# load udev only with a 2.6 kernel |
165 |
if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
166 |
then |
then |
167 |
|
# check if /dev/console exists outside tmpfs |
168 |
|
[ -c /dev/console ] ; need_redirect=$? |
169 |
|
|
170 |
# create a ramdisk for populating udev |
# create a ramdisk for populating udev |
171 |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
|
# tmpfs was suggested by Greg Kroah-Hartman |
|
172 |
# many video drivers needed exec access |
# many video drivers needed exec access |
173 |
mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 |
fstype=ramfs |
174 |
|
# tmpfs was suggested by Greg Kroah-Hartman |
175 |
|
kernel_supports_fs tmpfs && fstype=tmpfs |
176 |
|
mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M |
177 |
evaluate_retval |
evaluate_retval |
178 |
|
|
179 |
# if a device tarball exists load it and if it is activated |
# if a device tarball exists load it and if it is activated |
180 |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
181 |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
182 |
then |
then |
183 |
echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." |
echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
184 |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
185 |
evaluate_retval |
evaluate_retval |
186 |
fi |
fi |
187 |
|
|
188 |
# now load udev |
# other eeded device nodes with udev |
189 |
populate_udev |
seed_dev |
190 |
|
|
191 |
# 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 ] |
|
192 |
then |
then |
193 |
echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." |
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
194 |
|
then |
195 |
|
echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
196 |
|
echo "" > /proc/sys/kernel/hotplug |
197 |
|
evaluate_retval |
198 |
|
else |
199 |
|
echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." |
200 |
|
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
201 |
|
evaluate_retval |
202 |
|
fi |
203 |
|
else |
204 |
|
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
205 |
|
print_status failure |
206 |
|
fi |
207 |
|
|
208 |
elif [ -e /proc/sys/kernel/hotplug ] |
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
209 |
|
if [ ${need_redirect} -eq 1 ] |
210 |
then |
then |
211 |
echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." |
# we need to open fds 0 1 2 |
212 |
echo "/sbin/udev" > /proc/sys/kernel/hotplug |
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console |
213 |
else |
else |
214 |
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
/sbin/udevd --daemon |
215 |
fi |
fi |
216 |
evaluate_retval |
evaluate_retval |
217 |
|
|
218 |
|
/lib/udev/write_root_link_rule |
219 |
|
populate_udev |
220 |
|
|
221 |
|
# create nodes that udev can't |
222 |
|
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
223 |
|
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
224 |
|
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
225 |
|
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
226 |
|
print_status success |
227 |
|
|
228 |
|
# same thing as /dev/.devfsd |
229 |
|
touch /dev/.udev |
230 |
fi |
fi |
231 |
|
|
232 |
## load devpts ## |
## load devpts ## |
266 |
fi |
fi |
267 |
fi |
fi |
268 |
|
|
269 |
|
## load usbfs ## |
270 |
|
if kernel_supports_fs usbfs |
271 |
|
then |
272 |
|
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
273 |
|
mount -n -t usbfs usbfs /proc/bus/usb |
274 |
|
evaluate_retval |
275 |
|
fi |
276 |
|
|
277 |
### services state dir ### |
### services state dir ### |
278 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
279 |
mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k |
mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k |