1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.21 2008-12-22 22:01:15 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.22 2008-12-22 22:08:32 niro Exp $ |
3 |
|
|
4 |
source /etc/conf.d/rc |
source /etc/conf.d/rc |
5 |
source ${rc_functions} |
source ${rc_functions} |
6 |
|
|
7 |
|
# load udev helper functions |
8 |
|
source ${rc_base}/init.d/udev |
9 |
|
|
10 |
# get mage version |
# get mage version |
11 |
MAGEVER="$(< /etc/mageversion)" |
MAGEVER="$(< /etc/mageversion)" |
12 |
|
|
13 |
# source kernel config if exists |
# source kernel config if exists |
14 |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
15 |
|
|
|
udev_version() |
|
|
{ |
|
|
local version=0 |
|
|
|
|
|
if [[ -x /sbin/udev ]] |
|
|
then |
|
|
version=$(/sbin/udev -V) |
|
|
# We need it without a leading '0', else bash do the wrong thing |
|
|
version=${version##0} |
|
|
# Older udev's will print nothing |
|
|
[[ -z ${version} ]] && version=0 |
|
|
elif [[ -x /sbin/udevd ]] |
|
|
then |
|
|
version=$(/sbin/udevd --version) |
|
|
version=${version##0} |
|
|
[[ -z ${version} ]] && version=0 |
|
|
fi |
|
|
|
|
|
echo "${version}" |
|
|
} |
|
|
|
|
|
populate_udev() |
|
|
{ |
|
|
local opts |
|
|
|
|
|
# tell modprobe.sh to be verbose to $CONSOLE |
|
|
echo CONSOLE=${CONSOLE} > /dev/.udev_populate |
|
|
|
|
|
# populate /dev with devices already found by the kernel |
|
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
|
|
if [[ ${RC_COLDPLUG} = yes ]] |
|
|
then |
|
|
/sbin/udevtrigger |
|
|
else |
|
|
# do not run any init-scripts |
|
|
/sbin/udevadm control --env do_not_run_plug_service=1 |
|
|
|
|
|
# only create device nodes |
|
|
/sbin/udevtrigger --attr-match=dev |
|
|
|
|
|
# run persistent-net stuff |
|
|
/sbin/udevtrigger --subsystem-match=net |
|
|
fi |
|
|
evaluate_retval |
|
|
|
|
|
# loop until everything is finished |
|
|
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
|
|
/sbin/udevsettle --timeout=60 |
|
|
evaluate_retval |
|
|
|
|
|
# unset this variable |
|
|
udevadm control --env do_not_run_plug_service= |
|
|
|
|
|
rm -f /dev/.udev_populate |
|
|
return 0 |
|
|
} |
|
|
|
|
|
seed_dev() |
|
|
{ |
|
|
# seed /dev with some things that we know we need |
|
|
echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." |
|
|
( |
|
|
[ ! -c /dev/console ] && mknod /dev/console c 5 1 |
|
|
[ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1 |
|
|
[ ! -c /dev/null ] && mknod /dev/null c 1 3 |
|
|
|
|
|
# copy over any persistant things |
|
|
if [[ -d /lib/udev/devices ]] |
|
|
then |
|
|
cp -RPp /lib/udev/devices/* /dev 2>/dev/null |
|
|
fi |
|
|
|
|
|
# not provided by sysfs but needed |
|
|
ln -snf /proc/self/fd /dev/fd |
|
|
ln -snf fd/0 /dev/stdin |
|
|
ln -snf fd/1 /dev/stdout |
|
|
ln -snf fd/2 /dev/stderr |
|
|
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
|
|
|
|
|
# create problematic directories |
|
|
mkdir -p /dev/pts /dev/shm |
|
|
) |
|
|
evaluate_retval |
|
|
} |
|
|
|
|
16 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
17 |
|
|
18 |
[ "$1" != "" ] && runlevel=$1 |
[ "$1" != "" ] && runlevel=$1 |
51 |
|
|
52 |
|
|
53 |
#### load udev #### |
#### load udev #### |
54 |
# check if /dev/console exists outside tmpfs |
start_udev |
|
[ -c /dev/console ] ; need_redirect=$? |
|
|
|
|
|
# create a ramdisk for populating udev |
|
|
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
|
|
# many video drivers needed exec access |
|
|
fstype=ramfs |
|
|
# tmpfs was suggested by Greg Kroah-Hartman |
|
|
kernel_supports_fs tmpfs && fstype=tmpfs |
|
|
mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M |
|
|
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 |
|
|
|
|
|
# other eeded device nodes with udev |
|
|
seed_dev |
|
|
|
|
|
if [ -e /proc/sys/kernel/hotplug ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." |
|
|
echo "" > /proc/sys/kernel/hotplug |
|
|
evaluate_retval |
|
|
else |
|
|
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
|
|
print_status failure |
|
|
fi |
|
|
|
|
|
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
|
|
if [ ${need_redirect} -eq 1 ] |
|
|
then |
|
|
# we need to open fds 0 1 2 |
|
|
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console |
|
|
else |
|
|
/sbin/udevd --daemon |
|
|
fi |
|
|
evaluate_retval |
|
|
|
|
|
# write root_link rule |
|
|
/lib/udev/write_root_link_rule |
|
|
# populate udev device nodes |
|
|
populate_udev |
|
|
|
|
|
# create nodes that udev can't |
|
|
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
|
|
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
|
|
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
|
|
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
|
|
print_status success |
|
|
|
|
|
# same thing as /dev/.devfsd |
|
|
touch /dev/.udev |
|
55 |
## end udev ## |
## end udev ## |
56 |
|
|
57 |
|
|