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.23 2008-12-22 22:09:33 niro Exp $ |
3 |
|
|
4 |
source /etc/sysconfig/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)" |
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 |
|
|
|
# some needed functions functions |
|
|
populate_udev() { |
|
|
/sbin/udevstart |
|
|
|
|
|
# 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 |
|
|
ln -snf /proc/kcore /dev/core |
|
|
ln -snf /proc/asound/oss/sndstat /dev/sndstat |
|
|
|
|
|
# create problematic directories |
|
|
mkdir -p /dev/{pts,shm} |
|
|
|
|
|
# same as /dev/.devfsd |
|
|
touch /dev/.udev |
|
|
|
|
|
return 0 |
|
|
} |
|
|
|
|
16 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
17 |
|
|
18 |
[ "$1" != "" ] && runlevel=$1 |
[ "$1" != "" ] && runlevel=$1 |
21 |
then |
then |
22 |
echo |
echo |
23 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
24 |
echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" |
echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net" |
25 |
echo |
echo |
26 |
|
|
27 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
37 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
38 |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
39 |
|
|
40 |
# mount sys file system before udev or devfs (kernel-2.6) |
# mount sys file system before udev |
41 |
if [[ $(kernel_major_version) = 2.6 ]] |
if [ -d /sys ] |
42 |
then |
then |
43 |
if [ -d /sys ] |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
44 |
then |
mount -n -t sysfs sysfs /sys |
45 |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
evaluate_retval |
46 |
mount -n -t sysfs sysfs /sys |
else |
47 |
evaluate_retval |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
48 |
else |
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
49 |
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 |
|
50 |
fi |
fi |
51 |
|
|
|
## 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 |
|
52 |
|
|
53 |
#### load udev #### |
#### load udev #### |
54 |
# load udev only with a 2.6 kernel |
start_udev |
55 |
if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
## end udev ## |
|
then |
|
|
# create a ramdisk for populating udev |
|
|
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
|
|
# tmpfs was suggested by Greg Kroah-Hartman |
|
|
# many video drivers needed exec access |
|
|
mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 |
|
|
evaluate_retval |
|
56 |
|
|
|
# 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 with device nodes ..." |
|
|
tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
|
|
evaluate_retval |
|
|
fi |
|
57 |
|
|
58 |
# now load udev |
## load devpts ## |
59 |
populate_udev |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
60 |
|
# check if we really have devpts support |
61 |
# if hotplug support exists in the kernel use it to manage udev |
if kernel_supports_fs devpts |
62 |
if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] |
then |
63 |
|
# /dev/pts maybe not exists. |
64 |
|
# We only create this directory only if devfs was mounted, |
65 |
|
# or it will fail as / is still mounted readonly |
66 |
|
# udev has this dir already, only a sanity check for devfs |
67 |
|
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
68 |
then |
then |
69 |
echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." |
mkdir -p /dev/pts &> /dev/null || \ |
70 |
|
echo "Could not create /dev/pts !" |
71 |
|
fi |
72 |
|
|
73 |
elif [ -e /proc/sys/kernel/hotplug ] |
# now mount devpts |
74 |
|
if [ -d /dev/pts ] |
75 |
then |
then |
76 |
echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." |
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
77 |
echo "/sbin/udev" > /proc/sys/kernel/hotplug |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
78 |
else |
evaluate_retval |
|
echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" |
|
79 |
fi |
fi |
80 |
evaluate_retval |
else |
81 |
|
# devpts is not supported, give a warning |
82 |
|
echo -e ${COLRED}"No devpts filesystem found ..." |
83 |
|
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
84 |
|
echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
85 |
|
echo -e ${COLYELLOW}"or no pty's are available." |
86 |
|
echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
87 |
|
echo |
88 |
|
echo -e ${COLYELLOW}"Press any key to continue ..." |
89 |
|
read |
90 |
fi |
fi |
91 |
|
## end devpts ## |
92 |
|
|
93 |
## load devpts ## |
|
94 |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
## load usbfs ## |
95 |
if [[ $(kernel_major_version) = 2.6 ]] |
if kernel_supports_fs usbfs |
96 |
then |
then |
97 |
# check if we really have devpts support |
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
98 |
if kernel_supports_fs devpts |
mount -n -t usbfs usbfs /proc/bus/usb |
99 |
then |
evaluate_retval |
|
# /dev/pts maybe not exists. |
|
|
# We only create this directory only if devfs was mounted, |
|
|
# or it will fail as / is still mounted readonly |
|
|
# 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 |
|
|
fi |
|
100 |
fi |
fi |
101 |
|
## end usbfs ## |
102 |
|
|
103 |
### services state dir ### |
## services state dir ## |
104 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
105 |
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 |
106 |
evaluate_retval |
evaluate_retval |
123 |
then |
then |
124 |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
125 |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
126 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
127 |
evaluate_retval |
evaluate_retval |
128 |
fi |
fi |
129 |
fi |
fi |