1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $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 $ |
# $Id$ |
3 |
|
|
4 |
source /etc/sysconfig/rc |
source /etc/conf.d/rc |
5 |
source $rc_functions |
source ${rc_functions} |
6 |
|
|
7 |
# get mage version |
# get mage version |
8 |
MAGEVER="$(< /etc/mageversion)" |
MAGEVER="$(< /etc/mageversion)" |
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 |
udev_version() |
# override devicemanager helper functions |
14 |
{ |
if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]] |
15 |
local version=0 |
then |
16 |
|
source ${rc_base}/init.d/udev |
|
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 |
|
17 |
|
|
18 |
# not provided by sysfs but needed |
elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]] |
19 |
ln -snf /proc/self/fd /dev/fd |
then |
20 |
ln -snf fd/0 /dev/stdin |
source ${rc_base}/init.d/mdev |
21 |
ln -snf fd/1 /dev/stdout |
fi |
|
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 |
|
|
} |
|
22 |
|
|
23 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
24 |
|
|
26 |
|
|
27 |
if [[ $runlevel = sysinit ]] |
if [[ $runlevel = sysinit ]] |
28 |
then |
then |
29 |
echo |
rc_echo |
30 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
31 |
echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net" |
rc_echo "Copyright 2001-2011 Niels Rogalla; http://magellan-linux.net" |
32 |
echo |
rc_echo |
33 |
|
|
34 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
35 |
# no use of '/etc/rc.d/init.d/mountproc' anymore |
# no use of '/etc/rc.d/init.d/mountproc' anymore |
36 |
if [ ! -e /proc/mounts ] |
if [ ! -e /proc/mounts ] |
37 |
then |
then |
38 |
echo -e ${COLOREDSTAR}"Mounting proc file system ..." |
rc_print "Mounting proc file system ..." |
39 |
mount -n /proc |
mount -n /proc |
40 |
evaluate_retval |
evaluate_retval |
41 |
fi |
fi |
47 |
# mount sys file system before udev |
# mount sys file system before udev |
48 |
if [ -d /sys ] |
if [ -d /sys ] |
49 |
then |
then |
50 |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
rc_print "Mounting sysfs file system ..." |
51 |
mount -n -t sysfs sysfs /sys |
mount -n -t sysfs sysfs /sys |
52 |
evaluate_retval |
evaluate_retval |
53 |
else |
else |
54 |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
55 |
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
56 |
echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
57 |
fi |
fi |
58 |
|
|
59 |
|
# start device management |
60 |
#### load udev #### |
start_devicemanager |
|
# check if /dev/console exists outside tmpfs |
|
|
[ -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 |
|
|
## end udev ## |
|
|
|
|
61 |
|
|
62 |
## load devpts ## |
## load devpts ## |
63 |
# 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 |
71 |
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
72 |
then |
then |
73 |
mkdir -p /dev/pts &> /dev/null || \ |
mkdir -p /dev/pts &> /dev/null || \ |
74 |
echo "Could not create /dev/pts !" |
rc_echo "Could not create /dev/pts !" |
75 |
fi |
fi |
76 |
|
|
77 |
# now mount devpts |
# now mount devpts |
78 |
if [ -d /dev/pts ] |
if [ -d /dev/pts ] |
79 |
then |
then |
80 |
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
rc_print "Mounting devpts at /dev/pts ..." |
81 |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
82 |
evaluate_retval |
evaluate_retval |
83 |
fi |
fi |
84 |
else |
else |
85 |
# devpts is not supported, give a warning |
# devpts is not supported, give a warning |
86 |
echo -e ${COLRED}"No devpts filesystem found ..." |
rc_echo -e ${COLRED}"No devpts filesystem found ..." |
87 |
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
88 |
echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," |
rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
89 |
echo -e ${COLYELLOW}"or no pty's are available." |
rc_echo -e ${COLYELLOW}"or no pty's are available." |
90 |
echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." |
rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
91 |
echo |
rc_echo |
92 |
echo -e ${COLYELLOW}"Press any key to continue ..." |
rc_echo -e ${COLYELLOW}"Press any key to continue ..." |
93 |
read |
read |
94 |
fi |
fi |
95 |
## end devpts ## |
## end devpts ## |
98 |
## load usbfs ## |
## load usbfs ## |
99 |
if kernel_supports_fs usbfs |
if kernel_supports_fs usbfs |
100 |
then |
then |
101 |
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
rc_print "Mounting usbfs at /proc/bus/usb ..." |
102 |
mount -n -t usbfs usbfs /proc/bus/usb |
mount -n -t usbfs usbfs /proc/bus/usb |
103 |
evaluate_retval |
evaluate_retval |
104 |
fi |
fi |
105 |
## end usbfs ## |
## end usbfs ## |
106 |
|
|
107 |
## services state dir ## |
## services state dir ## |
108 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
rc_print "Mounting tmpfs at ${svcdir} ..." |
109 |
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 |
110 |
evaluate_retval |
evaluate_retval |
111 |
|
|
125 |
if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
126 |
[ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
[ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
127 |
then |
then |
128 |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
rc_print "Saving /dev device nodes ..." |
129 |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
130 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
131 |
evaluate_retval |
evaluate_retval |
132 |
fi |
fi |
133 |
|
|
134 |
|
# stop device management |
135 |
|
stop_devicemanager |
136 |
fi |
fi |
137 |
|
|
138 |
|
|
139 |
if [ "$runlevel" = "" ] |
if [ "$runlevel" = "" ] |
140 |
then |
then |
141 |
echo "Usage: $0 <runlevel>" >&2 |
rc_echo "Usage: $0 <runlevel>" >&2 |
142 |
exit 1 |
exit 1 |
143 |
fi |
fi |
144 |
|
|
148 |
|
|
149 |
if [ ! -d $rc_base/rc$runlevel.d ] |
if [ ! -d $rc_base/rc$runlevel.d ] |
150 |
then |
then |
151 |
echo "$rc_base/rc$runlevel.d does not exist" |
rc_echo "$rc_base/rc$runlevel.d does not exist" |
152 |
exit 1 |
exit 1 |
153 |
fi |
fi |
154 |
|
|
168 |
if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] |
if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] |
169 |
then |
then |
170 |
$WARNING |
$WARNING |
171 |
echo "$i can't be executed because it was" |
rc_echo "$i can't be executed because it was" |
172 |
echo "not started in the previous runlevel ($previous)" |
rc_echo "not started in the previous runlevel ($previous)" |
173 |
$NORMAL |
$NORMAL |
174 |
continue |
continue |
175 |
fi |
fi |