Annotation of /trunk/magellan-initscripts/rc/rc
Parent Directory | Revision Log
Revision 150 -
(hide annotations)
(download)
Sun Jul 3 21:34:35 2005 UTC (19 years, 2 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 7528 byte(s)
Sun Jul 3 21:34:35 2005 UTC (19 years, 2 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 7528 byte(s)
using now new is_fs_mounted functions and fixed fstype descriptions, some cosmetics fixes, merged runlevel 0 & 6, fixed some mount problems (-n to not write to mtab) etc..
1 | niro | 2 | #!/bin/bash |
2 | niro | 150 | # $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 $ |
3 | niro | 2 | |
4 | source /etc/sysconfig/rc | ||
5 | source $rc_functions | ||
6 | |||
7 | niro | 50 | # get mage version |
8 | MAGEVER="$(< /etc/mageversion)" | ||
9 | niro | 2 | |
10 | niro | 150 | # source kernel config if exists |
11 | niro | 2 | [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
12 | |||
13 | niro | 150 | # some needed functions functions |
14 | niro | 2 | populate_udev() { |
15 | /sbin/udevstart | ||
16 | |||
17 | niro | 150 | # not provided by sysfs but needed |
18 | niro | 2 | ln -snf /proc/self/fd /dev/fd |
19 | ln -snf fd/0 /dev/stdin | ||
20 | ln -snf fd/1 /dev/stdout | ||
21 | ln -snf fd/2 /dev/stderr | ||
22 | ln -snf /proc/kcore /dev/core | ||
23 | ln -snf /proc/asound/oss/sndstat /dev/sndstat | ||
24 | |||
25 | niro | 150 | # create problematic directories |
26 | niro | 2 | mkdir -p /dev/{pts,shm} |
27 | |||
28 | niro | 150 | # same as /dev/.devfsd |
29 | niro | 2 | touch /dev/.udev |
30 | niro | 71 | |
31 | niro | 2 | return 0 |
32 | } | ||
33 | |||
34 | trap "" INT QUIT TSTP | ||
35 | |||
36 | [ "$1" != "" ] && runlevel=$1 | ||
37 | |||
38 | niro | 150 | if [[ $runlevel = sysinit ]] |
39 | niro | 2 | then |
40 | echo | ||
41 | echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" | ||
42 | niro | 150 | echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" |
43 | niro | 2 | echo |
44 | |||
45 | niro | 150 | # mount proc filesystem, needed for bootsplash; |
46 | # no use of '/etc/rc.d/init.d/mountproc' anymore | ||
47 | niro | 2 | if [ ! -e /proc/mounts ] |
48 | then | ||
49 | echo -e ${COLOREDSTAR}"Mounting proc file system ..." | ||
50 | mount -n /proc | ||
51 | evaluate_retval | ||
52 | fi | ||
53 | |||
54 | niro | 150 | # set default verbose level for kernel messages |
55 | niro | 2 | [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
56 | echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk | ||
57 | |||
58 | niro | 150 | # mount sys file system before udev or devfs (kernel-2.6) |
59 | if [[ $(kernel_major_version) = 2.6 ]] | ||
60 | niro | 2 | then |
61 | if [ -d /sys ] | ||
62 | then | ||
63 | echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." | ||
64 | niro | 150 | mount -n -t sysfs sysfs /sys |
65 | niro | 2 | evaluate_retval |
66 | else | ||
67 | echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." | ||
68 | echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." | ||
69 | echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." | ||
70 | fi | ||
71 | fi | ||
72 | |||
73 | ## load devfs ## | ||
74 | niro | 150 | # load devfs only with a 2.4 kernel or its really wanted with a 2.6 |
75 | if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]] | ||
76 | niro | 2 | then |
77 | # start devfsd daemon, needed for bootsplash; | ||
78 | # no use of '/etc/rc.d/init.d/devfs' anymore | ||
79 | # check if devfs was mounted by the kernel, | ||
80 | # if not mount it (mbuild_livecd needs this one) | ||
81 | if [ ! -e /dev/.devfsd ] | ||
82 | then | ||
83 | echo -e ${COLOREDSTAR}"Mounting devfs file system ..." | ||
84 | niro | 150 | mount -n -t devfs devfs /dev |
85 | niro | 2 | evaluate_retval |
86 | fi | ||
87 | |||
88 | if [ -e /dev/.devfsd ] | ||
89 | then | ||
90 | echo -e ${COLOREDSTAR}"Starting devfsd ..." | ||
91 | ## directory /lib/dev-state !must! exists ## | ||
92 | /sbin/devfsd /dev &> /dev/null | ||
93 | evaluate_retval | ||
94 | else | ||
95 | echo -e ${COLRED}"No devfs filesystem found ..." | ||
96 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem." | ||
97 | echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux." | ||
98 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." | ||
99 | echo | ||
100 | echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..." | ||
101 | read | ||
102 | $rc_base/init.d/halt | ||
103 | fi | ||
104 | fi | ||
105 | |||
106 | #### load udev #### | ||
107 | niro | 150 | # load udev only with a 2.6 kernel |
108 | if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] | ||
109 | niro | 2 | then |
110 | niro | 150 | # create a ramdisk for populating udev |
111 | echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." | ||
112 | # tmpfs was suggested by Greg Kroah-Hartman | ||
113 | # many video drivers needed exec access | ||
114 | mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 | ||
115 | niro | 2 | evaluate_retval |
116 | |||
117 | niro | 150 | # if a device tarball exists load it and if it is activated |
118 | niro | 2 | echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
119 | niro | 150 | if [[ ${RC_DEVICE_TARBALL} = yes ]] |
120 | niro | 2 | then |
121 | echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." | ||
122 | tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev | ||
123 | evaluate_retval | ||
124 | fi | ||
125 | |||
126 | niro | 150 | # now load udev |
127 | niro | 2 | populate_udev |
128 | |||
129 | niro | 150 | # if hotplug support exists in the kernel use it to manage udev |
130 | niro | 2 | if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] |
131 | then | ||
132 | echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." | ||
133 | |||
134 | elif [ -e /proc/sys/kernel/hotplug ] | ||
135 | then | ||
136 | echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." | ||
137 | echo "/sbin/udev" > /proc/sys/kernel/hotplug | ||
138 | else | ||
139 | echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" | ||
140 | fi | ||
141 | evaluate_retval | ||
142 | fi | ||
143 | |||
144 | ## load devpts ## | ||
145 | # devfs/udev with 2.6 has no ptys, so devpts is also needed | ||
146 | niro | 150 | if [[ $(kernel_major_version) = 2.6 ]] |
147 | niro | 2 | then |
148 | # check if we really have devpts support | ||
149 | niro | 150 | if kernel_supports_fs devpts |
150 | niro | 2 | then |
151 | # /dev/pts maybe not exists. | ||
152 | # We only create this directory only if devfs was mounted, | ||
153 | # or it will fail as / is still mounted readonly | ||
154 | niro | 150 | # udev has this dir already, only a sanity check for devfs |
155 | if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs | ||
156 | niro | 2 | then |
157 | mkdir -p /dev/pts &> /dev/null || \ | ||
158 | echo "Could not create /dev/pts !" | ||
159 | fi | ||
160 | niro | 71 | |
161 | niro | 150 | # now mount devpts |
162 | niro | 2 | if [ -d /dev/pts ] |
163 | then | ||
164 | echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." | ||
165 | niro | 150 | mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
166 | niro | 2 | evaluate_retval |
167 | fi | ||
168 | else | ||
169 | # devpts is not supported, give a warning | ||
170 | echo -e ${COLRED}"No devpts filesystem found ..." | ||
171 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." | ||
172 | echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," | ||
173 | echo -e ${COLYELLOW}"or no pty's are available." | ||
174 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." | ||
175 | echo | ||
176 | echo -e ${COLYELLOW}"Press any key to continue ..." | ||
177 | read | ||
178 | fi | ||
179 | fi | ||
180 | |||
181 | ### services state dir ### | ||
182 | echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." | ||
183 | mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k | ||
184 | evaluate_retval | ||
185 | |||
186 | niro | 150 | # load bootsplash |
187 | niro | 2 | splash "rc_init" "${runlevel}" |
188 | fi | ||
189 | |||
190 | |||
191 | niro | 150 | if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] |
192 | niro | 2 | then |
193 | niro | 150 | # load bootsplash |
194 | niro | 2 | splash "rc_init" "${runlevel}" |
195 | |||
196 | # if requested save devices to a device tarball before halt | ||
197 | # only for kernels >=2.6 *and* udev | ||
198 | # make shure that udev is mounted but *not* devfs --> /dev/.devfsd | ||
199 | niro | 150 | if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
200 | [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] | ||
201 | niro | 2 | then |
202 | echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." | ||
203 | niro | 150 | ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
204 | niro | 2 | mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
205 | evaluate_retval | ||
206 | fi | ||
207 | fi | ||
208 | |||
209 | |||
210 | if [ "$runlevel" = "" ] | ||
211 | then | ||
212 | echo "Usage: $0 <runlevel>" >&2 | ||
213 | exit 1 | ||
214 | fi | ||
215 | |||
216 | niro | 150 | |
217 | niro | 2 | previous=$PREVLEVEL |
218 | [ "$previous" = "" ] && previous=N | ||
219 | |||
220 | if [ ! -d $rc_base/rc$runlevel.d ] | ||
221 | then | ||
222 | echo "$rc_base/rc$runlevel.d does not exist" | ||
223 | exit 1 | ||
224 | fi | ||
225 | |||
226 | if [ "$previous" != "N" ] | ||
227 | then | ||
228 | for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null) | ||
229 | do | ||
230 | |||
231 | check_script_status | ||
232 | |||
233 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} | ||
234 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | ||
235 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix | ||
236 | |||
237 | if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ] | ||
238 | then | ||
239 | if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] | ||
240 | then | ||
241 | $WARNING | ||
242 | echo "$i can't be executed because it was" | ||
243 | echo "not started in the previous runlevel ($previous)" | ||
244 | $NORMAL | ||
245 | continue | ||
246 | fi | ||
247 | fi | ||
248 | |||
249 | $i stop | ||
250 | error_value=$? | ||
251 | |||
252 | if [ "$error_value" != "0" ] | ||
253 | then | ||
254 | print_error_msg | ||
255 | fi | ||
256 | done | ||
257 | fi | ||
258 | |||
259 | for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null) | ||
260 | do | ||
261 | if [ "$previous" != "N" ] | ||
262 | then | ||
263 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} | ||
264 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix | ||
265 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | ||
266 | |||
267 | [ -f $prev_start ] && [ ! -f $stop ] && continue | ||
268 | fi | ||
269 | |||
270 | check_script_status | ||
271 | |||
272 | $i start | ||
273 | error_value=$? | ||
274 | |||
275 | if [ "$error_value" != "0" ] | ||
276 | then | ||
277 | print_error_msg | ||
278 | fi | ||
279 | done |
Properties
Name | Value |
---|---|
svn:executable | * |