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 $ |
# $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 ]] |
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 |
|
|
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 |
|
|
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." |
|
|
[[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev" |
|
|
/sbin/udevtrigger ${opts} |
|
|
evaluate_retval |
|
|
else |
|
|
echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." |
|
|
/sbin/udevstart |
|
|
evaluate_retval |
|
|
fi |
|
|
|
|
|
# loop until everything is finished |
|
|
echo -e ${COLOREDSTAR}" Letting udev process events ..." |
|
|
/sbin/udevsettle --timeout=60 |
|
|
evaluate_retval |
|
|
|
|
|
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 --preserve=all --recursive --update /lib/udev/devices/* /dev |
|
|
fi |
|
17 |
|
|
18 |
# not provided by sysfs but needed |
elif [[ ${RC_DEVICEMANAGER} = 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,shm} |
|
|
) |
|
|
evaluate_retval |
|
|
} |
|
22 |
|
|
23 |
trap "" INT QUIT TSTP |
trap "" INT QUIT TSTP |
24 |
|
|
28 |
then |
then |
29 |
echo |
echo |
30 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
31 |
echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net" |
echo -e "Copyright 2001-2010 Niels Rogalla; http://magellan-linux.net" |
32 |
echo |
echo |
33 |
|
|
34 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
44 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
45 |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
46 |
|
|
47 |
# mount sys file system before udev or devfs (kernel-2.6) |
# mount sys file system before udev |
48 |
if [[ $(kernel_major_version) = 2.6 ]] |
if [ -d /sys ] |
49 |
then |
then |
50 |
if [ -d /sys ] |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
51 |
then |
mount -n -t sysfs sysfs /sys |
52 |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
evaluate_retval |
53 |
mount -n -t sysfs sysfs /sys |
else |
54 |
evaluate_retval |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
55 |
else |
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
56 |
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 |
|
|
fi |
|
|
|
|
|
## 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 |
|
57 |
fi |
fi |
58 |
|
|
|
#### load udev #### |
|
|
# load udev only with a 2.6 kernel |
|
|
if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] |
|
|
then |
|
|
# check if /dev/console exists outside tmpfs |
|
|
[ -c /dev/console ] ; need_redirect=$? |
|
59 |
|
|
60 |
# create a ramdisk for populating udev |
#### load udev|mdev| #### |
61 |
echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." |
start_devicemanager |
62 |
# many video drivers needed exec access |
## end udev|mdev ## |
|
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 |
|
|
evaluate_retval |
|
63 |
|
|
|
# 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 |
|
64 |
|
|
65 |
# other eeded device nodes with udev |
## load devpts ## |
66 |
seed_dev |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
67 |
|
# check if we really have devpts support |
68 |
if [ -e /proc/sys/kernel/hotplug ] |
if kernel_supports_fs devpts |
69 |
|
then |
70 |
|
# /dev/pts maybe not exists. |
71 |
|
# We only create this directory only if devfs was mounted, |
72 |
|
# or it will fail as / is still mounted readonly |
73 |
|
# udev has this dir already, only a sanity check for devfs |
74 |
|
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
75 |
then |
then |
76 |
if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
mkdir -p /dev/pts &> /dev/null || \ |
77 |
then |
echo "Could not create /dev/pts !" |
|
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 |
|
78 |
fi |
fi |
79 |
|
|
80 |
echo -e ${COLOREDSTAR}" Starting udevd daemon ..." |
# now mount devpts |
81 |
if [ ${need_redirect} -eq 1 ] |
if [ -d /dev/pts ] |
82 |
then |
then |
83 |
# we need to open fds 0 1 2 |
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
84 |
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
85 |
else |
evaluate_retval |
|
/sbin/udevd --daemon |
|
86 |
fi |
fi |
87 |
evaluate_retval |
else |
88 |
|
# devpts is not supported, give a warning |
89 |
populate_udev |
echo -e ${COLRED}"No devpts filesystem found ..." |
90 |
|
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
91 |
# create nodes that udev can't |
echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
92 |
echo -e ${COLOREDSTAR}" Finializing udev configuration ..." |
echo -e ${COLYELLOW}"or no pty's are available." |
93 |
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null |
echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
94 |
[[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
echo |
95 |
[[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null |
echo -e ${COLYELLOW}"Press any key to continue ..." |
96 |
print_status success |
read |
|
|
|
|
# same thing as /dev/.devfsd |
|
|
touch /dev/.udev |
|
97 |
fi |
fi |
98 |
|
## end devpts ## |
99 |
|
|
100 |
## load devpts ## |
|
101 |
# devfs/udev with 2.6 has no ptys, so devpts is also needed |
## load usbfs ## |
102 |
if [[ $(kernel_major_version) = 2.6 ]] |
if kernel_supports_fs usbfs |
103 |
then |
then |
104 |
# check if we really have devpts support |
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
105 |
if kernel_supports_fs devpts |
mount -n -t usbfs usbfs /proc/bus/usb |
106 |
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 |
|
107 |
fi |
fi |
108 |
|
## end usbfs ## |
109 |
|
|
110 |
### services state dir ### |
## services state dir ## |
111 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
112 |
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 |
113 |
evaluate_retval |
evaluate_retval |
130 |
then |
then |
131 |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
132 |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
133 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
134 |
evaluate_retval |
evaluate_retval |
135 |
fi |
fi |
136 |
|
|
137 |
|
# stop udev|mdev now |
138 |
|
stop_devicemanager |
139 |
fi |
fi |
140 |
|
|
141 |
|
|