4 |
source /etc/conf.d/rc |
source /etc/conf.d/rc |
5 |
source ${rc_functions} |
source ${rc_functions} |
6 |
|
|
7 |
# load udev helper functions |
# source kernel config if exists |
8 |
source ${rc_base}/init.d/udev |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
9 |
|
|
10 |
# get mage version |
# get mage version |
11 |
MAGEVER="$(< /etc/mageversion)" |
if [[ -f /etc/os-release ]] |
12 |
|
then |
13 |
|
MAGEVER="$(read_os_release version_id)" |
14 |
|
elif [ -f /etc/mageversion ] |
15 |
|
then |
16 |
|
MAGEVER="$(< /etc/mageversion)" |
17 |
|
else |
18 |
|
MAGEVER="unkown" |
19 |
|
fi |
20 |
|
|
21 |
# source kernel config if exists |
# source kernel config if exists |
22 |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
[ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
23 |
|
|
24 |
trap "" INT QUIT TSTP |
# override devicemanager helper functions |
25 |
|
if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]] |
26 |
[[ ! -z $1 ]] && runlevel=$1 |
then |
27 |
|
source ${rc_base}/init.d/udev |
28 |
|
|
29 |
if [[ -z ${runlevel} ]] |
elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]] |
30 |
then |
then |
31 |
echo "Usage: $0 <runlevel>" >&2 |
source ${rc_base}/init.d/mdev |
|
exit 1 |
|
32 |
fi |
fi |
33 |
|
|
34 |
|
trap "" INT QUIT TSTP |
35 |
|
|
36 |
|
[ "$1" != "" ] && runlevel=$1 |
37 |
|
# export runlevel variable to make it accessible for other rc-scripts |
38 |
|
export runlevel |
39 |
|
|
40 |
if [[ $runlevel = sysinit ]] |
if [[ $runlevel = sysinit ]] |
41 |
then |
then |
42 |
echo |
rc_echo |
43 |
echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
44 |
echo -e "Copyright 2001-2010 Niels Rogalla; http://magellan-linux.net" |
rc_echo "Copyright 2001-2012 Niels Rogalla; http://magellan-linux.net" |
45 |
echo |
rc_echo |
46 |
|
|
47 |
# mount proc filesystem, needed for bootsplash; |
# mount proc filesystem, needed for bootsplash; |
48 |
# no use of '/etc/rc.d/init.d/mountproc' anymore |
# no use of '/etc/rc.d/init.d/mountproc' anymore |
49 |
if [ ! -e /proc/mounts ] |
if [ ! -e /proc/mounts ] |
50 |
then |
then |
51 |
echo -e ${COLOREDSTAR}"Mounting proc file system ..." |
rc_print "Mounting proc file system ..." |
52 |
mount -n /proc |
mount -n /proc |
53 |
evaluate_retval |
evaluate_retval |
54 |
fi |
fi |
55 |
|
|
56 |
|
# load bootsplash |
57 |
|
splash "rc_init" "${runlevel}" |
58 |
|
|
59 |
# set default verbose level for kernel messages |
# set default verbose level for kernel messages |
60 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
[ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
61 |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
63 |
# mount sys file system before udev |
# mount sys file system before udev |
64 |
if [ -d /sys ] |
if [ -d /sys ] |
65 |
then |
then |
66 |
echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." |
if [ ! -e /sys/kernel/notes ] |
67 |
mount -n -t sysfs sysfs /sys |
then |
68 |
evaluate_retval |
rc_print "Mounting sysfs file system ..." |
69 |
|
mount -n -t sysfs sysfs /sys |
70 |
|
evaluate_retval |
71 |
|
fi |
72 |
else |
else |
73 |
echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
rc_echo -e ${COLRED}"Fatal: mountpoint /sys missing ..." |
74 |
echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
75 |
echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
76 |
fi |
fi |
77 |
|
|
78 |
#### load udev #### |
# start device management |
79 |
start_udev |
start_devicemanager |
|
## end udev ## |
|
80 |
|
|
81 |
## load devpts ## |
## load devpts ## |
82 |
# 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 |
90 |
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
91 |
then |
then |
92 |
mkdir -p /dev/pts &> /dev/null || \ |
mkdir -p /dev/pts &> /dev/null || \ |
93 |
echo "Could not create /dev/pts !" |
rc_echo "Could not create /dev/pts !" |
94 |
fi |
fi |
95 |
|
|
96 |
# now mount devpts |
# now mount devpts |
97 |
if [ -d /dev/pts ] |
if [ -d /dev/pts ] |
98 |
then |
then |
99 |
echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." |
rc_print "Mounting devpts at /dev/pts ..." |
100 |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
101 |
evaluate_retval |
evaluate_retval |
102 |
fi |
fi |
103 |
else |
else |
104 |
# devpts is not supported, give a warning |
# devpts is not supported, give a warning |
105 |
echo -e ${COLRED}"No devpts filesystem found ..." |
rc_echo -e ${COLRED}"No devpts filesystem found ..." |
106 |
echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
107 |
echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
108 |
echo -e ${COLYELLOW}"or no pty's are available." |
rc_echo -e ${COLYELLOW}"or no pty's are available." |
109 |
echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
110 |
echo |
rc_echo |
111 |
echo -e ${COLYELLOW}"Press any key to continue ..." |
rc_echo -e ${COLYELLOW}"Press any key to continue ..." |
112 |
read |
read |
113 |
fi |
fi |
114 |
## end devpts ## |
## end devpts ## |
117 |
## load usbfs ## |
## load usbfs ## |
118 |
if kernel_supports_fs usbfs |
if kernel_supports_fs usbfs |
119 |
then |
then |
120 |
echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..." |
rc_print "Mounting usbfs at /proc/bus/usb ..." |
121 |
mount -n -t usbfs usbfs /proc/bus/usb |
mount -n -t usbfs usbfs /proc/bus/usb |
122 |
evaluate_retval |
evaluate_retval |
123 |
fi |
fi |
124 |
## end usbfs ## |
## end usbfs ## |
125 |
|
|
126 |
## services state dir ## |
## services state dir ## |
127 |
echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." |
rc_print "Mounting tmpfs at ${svcdir} ..." |
128 |
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 |
129 |
evaluate_retval |
evaluate_retval |
|
|
|
|
# load bootsplash |
|
|
splash "rc_init" "${runlevel}" |
|
130 |
fi |
fi |
131 |
|
|
132 |
if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]] |
if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]] |
136 |
|
|
137 |
# if requested save devices to a device tarball before halt |
# if requested save devices to a device tarball before halt |
138 |
# only for kernels >=2.6 *and* udev |
# only for kernels >=2.6 *and* udev |
139 |
# make shure that udev is mounted but *not* devfs --> /dev/.devfsd |
# make sure that udev is mounted but *not* devfs --> /dev/.devfsd |
140 |
if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
141 |
[ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
[ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
142 |
then |
then |
143 |
echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." |
rc_print "Saving /dev device nodes ..." |
144 |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
145 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
146 |
evaluate_retval |
evaluate_retval |
147 |
fi |
fi |
148 |
|
|
149 |
# stop udev now |
# stop device management |
150 |
stop_udev |
stop_devicemanager |
151 |
|
|
152 |
# run through all runlevel scripts |
# run through all runlevel scripts |
153 |
for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null) |
for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null) |
181 |
fi |
fi |
182 |
done |
done |
183 |
fi |
fi |
184 |
|
|
185 |
|
if [[ ${runlevel} = boot ]] || [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]] |
186 |
|
then |
187 |
|
# exit bootsplash |
188 |
|
splash "rc_exit" "${runlevel}" |
189 |
|
fi |