1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.13 2007-03-04 13:24:34 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.19 2008-03-22 17:55:21 niro Exp $ |
3 |
|
|
4 |
source /etc/sysconfig/rc |
source /etc/sysconfig/rc |
5 |
source $rc_functions |
source $rc_functions |
21 |
version=${version##0} |
version=${version##0} |
22 |
# Older udev's will print nothing |
# Older udev's will print nothing |
23 |
[[ -z ${version} ]] && version=0 |
[[ -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 |
fi |
30 |
|
|
31 |
echo "${version}" |
echo "${version}" |
39 |
echo CONSOLE=${CONSOLE} > /dev/.udev_populate |
echo CONSOLE=${CONSOLE} > /dev/.udev_populate |
40 |
|
|
41 |
# populate /dev with devices already found by the kernel |
# populate /dev with devices already found by the kernel |
42 |
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
43 |
|
if [[ ${RC_COLDPLUG} = yes ]] |
44 |
then |
then |
45 |
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
/sbin/udevtrigger |
|
[[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev" |
|
|
/sbin/udevtrigger ${opts} |
|
|
evaluate_retval |
|
46 |
else |
else |
47 |
echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." |
# do not run any init-scripts |
48 |
/sbin/udevstart |
/sbin/udevadm control --env do_not_run_plug_service=1 |
49 |
evaluate_retval |
|
50 |
|
# only create device nodes |
51 |
|
/sbin/udevtrigger --attr-match=dev |
52 |
|
|
53 |
|
# run persistent-net stuff |
54 |
|
/sbin/udevtrigger --subsystem-match=net |
55 |
fi |
fi |
56 |
|
evaluate_retval |
57 |
|
|
58 |
# loop until everything is finished |
# loop until everything is finished |
59 |
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
60 |
/sbin/udevsettle --timeout=60 |
/sbin/udevsettle --timeout=60 |
61 |
evaluate_retval |
evaluate_retval |
62 |
|
|
63 |
|
# unset this variable |
64 |
|
udevadm control --env do_not_run_plug_service= |
65 |
|
|
66 |
rm -f /dev/.udev_populate |
rm -f /dev/.udev_populate |
67 |
return 0 |
return 0 |
68 |
} |
} |
79 |
# copy over any persistant things |
# copy over any persistant things |
80 |
if [[ -d /lib/udev/devices ]] |
if [[ -d /lib/udev/devices ]] |
81 |
then |
then |
82 |
cp --preserve=all --recursive --update /lib/udev/devices/* /dev |
cp -RPp /lib/udev/devices/* /dev 2>/dev/null |
83 |
fi |
fi |
84 |
|
|
85 |
# not provided by sysfs but needed |
# not provided by sysfs but needed |
88 |
ln -snf fd/1 /dev/stdout |
ln -snf fd/1 /dev/stdout |
89 |
ln -snf fd/2 /dev/stderr |
ln -snf fd/2 /dev/stderr |
90 |
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
91 |
|
|
92 |
# create problematic directories |
# create problematic directories |
93 |
mkdir -p /dev/{pts,shm} |
mkdir -p /dev/pts /dev/shm |
94 |
) |
) |
95 |
evaluate_retval |
evaluate_retval |
96 |
} |
} |
103 |
then |
then |
104 |
echo |
echo |
105 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
106 |
echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net" |
echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net" |
107 |
echo |
echo |
108 |
|
|
109 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
119 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
120 |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
121 |
|
|
122 |
# mount sys file system before udev or devfs (kernel-2.6) |
# mount sys file system before udev |
123 |
if [[ $(kernel_major_version) = 2.6 ]] |
if [ -d /sys ] |
124 |
then |
then |
125 |
if [ -d /sys ] |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
126 |
then |
mount -n -t sysfs sysfs /sys |
127 |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
evaluate_retval |
128 |
mount -n -t sysfs sysfs /sys |
else |
129 |
evaluate_retval |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
130 |
else |
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
131 |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
|
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
|
|
echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
|
|
fi |
|
132 |
fi |
fi |
133 |
|
|
|
## load devfs ## |
|
|
# load devfs only with a 2.4 kernel or its really wanted with a 2.6 |
|
|
if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]] |
|
|
then |
|
|
# start devfsd daemon, needed for bootsplash; |
|
|
# no use of '/etc/rc.d/init.d/devfs' anymore |
|
|
# check if devfs was mounted by the kernel, |
|
|
# if not mount it (mbuild_livecd needs this one) |
|
|
if [ ! -e /dev/.devfsd ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}"Mounting devfs file system ..." |
|
|
mount -n -t devfs devfs /dev |
|
|
evaluate_retval |
|
|
fi |
|
|
|
|
|
if [ -e /dev/.devfsd ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}"Starting devfsd ..." |
|
|
## directory /lib/dev-state !must! exists ## |
|
|
/sbin/devfsd /dev &> /dev/null |
|
|
evaluate_retval |
|
|
else |
|
|
echo -e ${COLRED}"No devfs filesystem found ..." |
|
|
echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem." |
|
|
echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux." |
|
|
echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
|
|
echo |
|
|
echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..." |
|
|
read |
|
|
$rc_base/init.d/halt |
|
|
fi |
|
|
fi |
|
134 |
|
|
135 |
#### load udev #### |
#### load udev #### |
136 |
# load udev only with a 2.6 kernel |
# check if /dev/console exists outside tmpfs |
137 |
if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
[ -c /dev/console ] ; need_redirect=$? |
|
then |
|
|
# check if /dev/console exists outside tmpfs |
|
|
[ -c /dev/console ] ; need_redirect=$? |
|
138 |
|
|
139 |
# create a ramdisk for populating udev |
# create a ramdisk for populating udev |
140 |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
141 |
# many video drivers needed exec access |
# many video drivers needed exec access |
142 |
fstype=ramfs |
fstype=ramfs |
143 |
# tmpfs was suggested by Greg Kroah-Hartman |
# tmpfs was suggested by Greg Kroah-Hartman |
144 |
kernel_supports_fs tmpfs && fstype=tmpfs |
kernel_supports_fs tmpfs && fstype=tmpfs |
145 |
mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755 |
mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M |
146 |
evaluate_retval |
evaluate_retval |
|
|
|
|
# if a device tarball exists load it and if it is activated |
|
|
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
|
|
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
|
|
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
|
|
evaluate_retval |
|
|
fi |
|
147 |
|
|
148 |
# other eeded device nodes with udev |
# if a device tarball exists load it and if it is activated |
149 |
seed_dev |
echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
150 |
|
if [[ ${RC_DEVICE_TARBALL} = yes ]] |
151 |
|
then |
152 |
|
echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
153 |
|
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
154 |
|
evaluate_retval |
155 |
|
fi |
156 |
|
|
157 |
if [ -e /proc/sys/kernel/hotplug ] |
# other eeded device nodes with udev |
158 |
then |
seed_dev |
|
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
|
|
echo "" > /proc/sys/kernel/hotplug |
|
|
evaluate_retval |
|
|
else |
|
|
echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." |
|
|
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
|
|
evaluate_retval |
|
|
fi |
|
|
else |
|
|
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
|
|
print_status failure |
|
|
fi |
|
159 |
|
|
160 |
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
if [ -e /proc/sys/kernel/hotplug ] |
161 |
if [ ${need_redirect} -eq 1 ] |
then |
162 |
then |
echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
163 |
# we need to open fds 0 1 2 |
echo "" > /proc/sys/kernel/hotplug |
|
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console |
|
|
else |
|
|
/sbin/udevd --daemon |
|
|
fi |
|
164 |
evaluate_retval |
evaluate_retval |
165 |
|
else |
166 |
|
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
167 |
|
print_status failure |
168 |
|
fi |
169 |
|
|
170 |
populate_udev |
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
171 |
|
if [ ${need_redirect} -eq 1 ] |
172 |
|
then |
173 |
|
# we need to open fds 0 1 2 |
174 |
|
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console |
175 |
|
else |
176 |
|
/sbin/udevd --daemon |
177 |
|
fi |
178 |
|
evaluate_retval |
179 |
|
|
180 |
# create nodes that udev can't |
# write root_link rule |
181 |
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
/lib/udev/write_root_link_rule |
182 |
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
# populate udev device nodes |
183 |
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
populate_udev |
184 |
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
|
185 |
print_status success |
# create nodes that udev can't |
186 |
|
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
187 |
|
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
188 |
|
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
189 |
|
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
190 |
|
print_status success |
191 |
|
|
192 |
|
# same thing as /dev/.devfsd |
193 |
|
touch /dev/.udev |
194 |
|
## end udev ## |
195 |
|
|
|
# same thing as /dev/.devfsd |
|
|
touch /dev/.udev |
|
|
fi |
|
196 |
|
|
197 |
## load devpts ## |
## load devpts ## |
198 |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
199 |
if [[ $(kernel_major_version) = 2.6 ]] |
# check if we really have devpts support |
200 |
|
if kernel_supports_fs devpts |
201 |
then |
then |
202 |
# check if we really have devpts support |
# /dev/pts maybe not exists. |
203 |
if kernel_supports_fs devpts |
# We only create this directory only if devfs was mounted, |
204 |
|
# or it will fail as / is still mounted readonly |
205 |
|
# udev has this dir already, only a sanity check for devfs |
206 |
|
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
207 |
|
then |
208 |
|
mkdir -p /dev/pts &> /dev/null || \ |
209 |
|
echo "Could not create /dev/pts !" |
210 |
|
fi |
211 |
|
|
212 |
|
# now mount devpts |
213 |
|
if [ -d /dev/pts ] |
214 |
then |
then |
215 |
# /dev/pts maybe not exists. |
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
216 |
# We only create this directory only if devfs was mounted, |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
217 |
# or it will fail as / is still mounted readonly |
evaluate_retval |
|
# udev has this dir already, only a sanity check for devfs |
|
|
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
|
|
then |
|
|
mkdir -p /dev/pts &> /dev/null || \ |
|
|
echo "Could not create /dev/pts !" |
|
|
fi |
|
|
|
|
|
# now mount devpts |
|
|
if [ -d /dev/pts ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
|
|
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
|
|
evaluate_retval |
|
|
fi |
|
|
else |
|
|
# devpts is not supported, give a warning |
|
|
echo -e ${COLRED}"No devpts filesystem found ..." |
|
|
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
|
|
echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," |
|
|
echo -e ${COLYELLOW}"or no pty's are available." |
|
|
echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
|
|
echo |
|
|
echo -e ${COLYELLOW}"Press any key to continue ..." |
|
|
read |
|
218 |
fi |
fi |
219 |
|
else |
220 |
|
# devpts is not supported, give a warning |
221 |
|
echo -e ${COLRED}"No devpts filesystem found ..." |
222 |
|
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
223 |
|
echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," |
224 |
|
echo -e ${COLYELLOW}"or no pty's are available." |
225 |
|
echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
226 |
|
echo |
227 |
|
echo -e ${COLYELLOW}"Press any key to continue ..." |
228 |
|
read |
229 |
|
fi |
230 |
|
## end devpts ## |
231 |
|
|
232 |
|
|
233 |
|
## load usbfs ## |
234 |
|
if kernel_supports_fs usbfs |
235 |
|
then |
236 |
|
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
237 |
|
mount -n -t usbfs usbfs /proc/bus/usb |
238 |
|
evaluate_retval |
239 |
fi |
fi |
240 |
|
## end usbfs ## |
241 |
|
|
242 |
### services state dir ### |
## services state dir ## |
243 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
244 |
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 |
245 |
evaluate_retval |
evaluate_retval |