Annotation of /trunk/magellan-initscripts/etc/rc.d/init.d/rc
Parent Directory | Revision Log
Revision 395 -
(hide annotations)
(download)
Tue Oct 31 10:50:22 2006 UTC (17 years, 10 months ago) by niro
File size: 9235 byte(s)
Tue Oct 31 10:50:22 2006 UTC (17 years, 10 months ago) by niro
File size: 9235 byte(s)
fixed a typo
1 | niro | 2 | #!/bin/bash |
2 | niro | 395 | # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.11 2006-10-31 10:50:22 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 | 319 | udev_version() |
14 | { | ||
15 | local version=0 | ||
16 | |||
17 | if [[ -x /sbin/udev ]] | ||
18 | then | ||
19 | version=$(/sbin/udev -V) | ||
20 | # We need it without a leading '0', else bash do the wrong thing | ||
21 | version=${version##0} | ||
22 | # Older udev's will print nothing | ||
23 | [[ -z ${version} ]] && version=0 | ||
24 | fi | ||
25 | |||
26 | echo "${version}" | ||
27 | } | ||
28 | |||
29 | populate_udev() | ||
30 | { | ||
31 | niro | 394 | local opts |
32 | niro | 318 | |
33 | # populate /dev with devices already found by the kernel | ||
34 | niro | 376 | if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
35 | niro | 318 | then |
36 | echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." | ||
37 | niro | 394 | [[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev" |
38 | /sbin/udevtrigger ${opts} | ||
39 | niro | 318 | evaluate_retval |
40 | else | ||
41 | echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." | ||
42 | niro | 2 | /sbin/udevstart |
43 | niro | 318 | evaluate_retval |
44 | fi | ||
45 | niro | 2 | |
46 | niro | 318 | # loop until everything is finished |
47 | echo -e ${COLOREDSTAR}" Letting udev process events ..." | ||
48 | niro | 394 | /sbin/udevsettle --timeout=60 |
49 | niro | 318 | evaluate_retval |
50 | |||
51 | return 0 | ||
52 | } | ||
53 | |||
54 | niro | 319 | seed_dev() |
55 | { | ||
56 | niro | 318 | # seed /dev with some things that we know we need |
57 | echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." | ||
58 | ( | ||
59 | # copy over any persistant things | ||
60 | niro | 394 | if [[ -d /lib/udev/devices ]] |
61 | then | ||
62 | cp --preserve=all --recursive --update /lib/udev/devices/* /dev | ||
63 | fi | ||
64 | niro | 318 | |
65 | niro | 150 | # not provided by sysfs but needed |
66 | niro | 2 | ln -snf /proc/self/fd /dev/fd |
67 | ln -snf fd/0 /dev/stdin | ||
68 | ln -snf fd/1 /dev/stdout | ||
69 | ln -snf fd/2 /dev/stderr | ||
70 | niro | 318 | [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core |
71 | |||
72 | niro | 150 | # create problematic directories |
73 | niro | 2 | mkdir -p /dev/{pts,shm} |
74 | niro | 318 | ) |
75 | evaluate_retval | ||
76 | } | ||
77 | niro | 2 | |
78 | trap "" INT QUIT TSTP | ||
79 | |||
80 | [ "$1" != "" ] && runlevel=$1 | ||
81 | |||
82 | niro | 150 | if [[ $runlevel = sysinit ]] |
83 | niro | 2 | then |
84 | echo | ||
85 | echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" | ||
86 | niro | 345 | echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net" |
87 | niro | 2 | echo |
88 | |||
89 | niro | 150 | # mount proc filesystem, needed for bootsplash; |
90 | # no use of '/etc/rc.d/init.d/mountproc' anymore | ||
91 | niro | 2 | if [ ! -e /proc/mounts ] |
92 | then | ||
93 | echo -e ${COLOREDSTAR}"Mounting proc file system ..." | ||
94 | mount -n /proc | ||
95 | evaluate_retval | ||
96 | fi | ||
97 | |||
98 | niro | 150 | # set default verbose level for kernel messages |
99 | niro | 2 | [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
100 | echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk | ||
101 | |||
102 | niro | 150 | # mount sys file system before udev or devfs (kernel-2.6) |
103 | if [[ $(kernel_major_version) = 2.6 ]] | ||
104 | niro | 2 | then |
105 | if [ -d /sys ] | ||
106 | then | ||
107 | echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." | ||
108 | niro | 150 | mount -n -t sysfs sysfs /sys |
109 | niro | 2 | evaluate_retval |
110 | else | ||
111 | echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." | ||
112 | echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." | ||
113 | echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." | ||
114 | fi | ||
115 | fi | ||
116 | |||
117 | ## load devfs ## | ||
118 | niro | 150 | # load devfs only with a 2.4 kernel or its really wanted with a 2.6 |
119 | if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]] | ||
120 | niro | 2 | then |
121 | # start devfsd daemon, needed for bootsplash; | ||
122 | # no use of '/etc/rc.d/init.d/devfs' anymore | ||
123 | # check if devfs was mounted by the kernel, | ||
124 | # if not mount it (mbuild_livecd needs this one) | ||
125 | if [ ! -e /dev/.devfsd ] | ||
126 | then | ||
127 | echo -e ${COLOREDSTAR}"Mounting devfs file system ..." | ||
128 | niro | 150 | mount -n -t devfs devfs /dev |
129 | niro | 2 | evaluate_retval |
130 | fi | ||
131 | |||
132 | if [ -e /dev/.devfsd ] | ||
133 | then | ||
134 | echo -e ${COLOREDSTAR}"Starting devfsd ..." | ||
135 | ## directory /lib/dev-state !must! exists ## | ||
136 | /sbin/devfsd /dev &> /dev/null | ||
137 | evaluate_retval | ||
138 | else | ||
139 | echo -e ${COLRED}"No devfs filesystem found ..." | ||
140 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem." | ||
141 | echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux." | ||
142 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." | ||
143 | echo | ||
144 | echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..." | ||
145 | read | ||
146 | $rc_base/init.d/halt | ||
147 | fi | ||
148 | fi | ||
149 | |||
150 | #### load udev #### | ||
151 | niro | 150 | # load udev only with a 2.6 kernel |
152 | if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] | ||
153 | niro | 2 | then |
154 | niro | 150 | # create a ramdisk for populating udev |
155 | echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." | ||
156 | niro | 394 | # many video drivers needed exec access |
157 | fstype=ramfs | ||
158 | niro | 150 | # tmpfs was suggested by Greg Kroah-Hartman |
159 | niro | 395 | kernel_supports_fs tmpfs && fstype=tmpfs |
160 | niro | 394 | mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755 |
161 | niro | 2 | evaluate_retval |
162 | |||
163 | niro | 150 | # if a device tarball exists load it and if it is activated |
164 | niro | 2 | echo -e ${COLOREDSTAR}"Configurating system to use udev ..." |
165 | niro | 150 | if [[ ${RC_DEVICE_TARBALL} = yes ]] |
166 | niro | 2 | then |
167 | niro | 318 | echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." |
168 | niro | 2 | tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev |
169 | evaluate_retval | ||
170 | fi | ||
171 | |||
172 | niro | 318 | # other eeded device nodes with udev |
173 | seed_dev | ||
174 | niro | 2 | |
175 | niro | 318 | if [ -e /proc/sys/kernel/hotplug ] |
176 | niro | 2 | then |
177 | niro | 376 | if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] |
178 | niro | 318 | then |
179 | echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." | ||
180 | echo "" > /proc/sys/kernel/hotplug | ||
181 | evaluate_retval | ||
182 | niro | 394 | else |
183 | niro | 318 | echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." |
184 | echo "/sbin/udevsend" > /proc/sys/kernel/hotplug | ||
185 | evaluate_retval | ||
186 | fi | ||
187 | niro | 2 | else |
188 | echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" | ||
189 | niro | 318 | print_status failure |
190 | niro | 2 | fi |
191 | niro | 318 | |
192 | echo -e ${COLOREDSTAR}" Starting udevd daemon ..." | ||
193 | /sbin/udevd --daemon | ||
194 | niro | 2 | evaluate_retval |
195 | niro | 318 | |
196 | populate_udev | ||
197 | |||
198 | # create nodes that udev can't | ||
199 | echo -e ${COLOREDSTAR}" Finializing udev configuration ..." | ||
200 | [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null | ||
201 | [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null | ||
202 | [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null | ||
203 | print_status success | ||
204 | |||
205 | # same thing as /dev/.devfsd | ||
206 | touch /dev/.udev | ||
207 | niro | 2 | fi |
208 | |||
209 | ## load devpts ## | ||
210 | # devfs/udev with 2.6 has no ptys, so devpts is also needed | ||
211 | niro | 150 | if [[ $(kernel_major_version) = 2.6 ]] |
212 | niro | 2 | then |
213 | # check if we really have devpts support | ||
214 | niro | 150 | if kernel_supports_fs devpts |
215 | niro | 2 | then |
216 | # /dev/pts maybe not exists. | ||
217 | # We only create this directory only if devfs was mounted, | ||
218 | # or it will fail as / is still mounted readonly | ||
219 | niro | 150 | # udev has this dir already, only a sanity check for devfs |
220 | if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs | ||
221 | niro | 2 | then |
222 | mkdir -p /dev/pts &> /dev/null || \ | ||
223 | echo "Could not create /dev/pts !" | ||
224 | fi | ||
225 | niro | 71 | |
226 | niro | 150 | # now mount devpts |
227 | niro | 2 | if [ -d /dev/pts ] |
228 | then | ||
229 | echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." | ||
230 | niro | 150 | mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
231 | niro | 2 | evaluate_retval |
232 | fi | ||
233 | else | ||
234 | # devpts is not supported, give a warning | ||
235 | echo -e ${COLRED}"No devpts filesystem found ..." | ||
236 | echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." | ||
237 | echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," | ||
238 | echo -e ${COLYELLOW}"or no pty's are available." | ||
239 | echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." | ||
240 | echo | ||
241 | echo -e ${COLYELLOW}"Press any key to continue ..." | ||
242 | read | ||
243 | fi | ||
244 | fi | ||
245 | |||
246 | ### services state dir ### | ||
247 | echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." | ||
248 | mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k | ||
249 | evaluate_retval | ||
250 | |||
251 | niro | 150 | # load bootsplash |
252 | niro | 2 | splash "rc_init" "${runlevel}" |
253 | fi | ||
254 | |||
255 | |||
256 | niro | 150 | if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] |
257 | niro | 2 | then |
258 | niro | 150 | # load bootsplash |
259 | niro | 2 | splash "rc_init" "${runlevel}" |
260 | |||
261 | # if requested save devices to a device tarball before halt | ||
262 | # only for kernels >=2.6 *and* udev | ||
263 | # make shure that udev is mounted but *not* devfs --> /dev/.devfsd | ||
264 | niro | 150 | if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
265 | [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] | ||
266 | niro | 2 | then |
267 | echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." | ||
268 | niro | 150 | ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
269 | niro | 2 | mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 |
270 | evaluate_retval | ||
271 | fi | ||
272 | fi | ||
273 | |||
274 | |||
275 | if [ "$runlevel" = "" ] | ||
276 | then | ||
277 | echo "Usage: $0 <runlevel>" >&2 | ||
278 | exit 1 | ||
279 | fi | ||
280 | |||
281 | niro | 150 | |
282 | niro | 2 | previous=$PREVLEVEL |
283 | [ "$previous" = "" ] && previous=N | ||
284 | |||
285 | if [ ! -d $rc_base/rc$runlevel.d ] | ||
286 | then | ||
287 | echo "$rc_base/rc$runlevel.d does not exist" | ||
288 | exit 1 | ||
289 | fi | ||
290 | |||
291 | if [ "$previous" != "N" ] | ||
292 | then | ||
293 | for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null) | ||
294 | do | ||
295 | |||
296 | check_script_status | ||
297 | |||
298 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} | ||
299 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | ||
300 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix | ||
301 | |||
302 | if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ] | ||
303 | then | ||
304 | if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] | ||
305 | then | ||
306 | $WARNING | ||
307 | echo "$i can't be executed because it was" | ||
308 | echo "not started in the previous runlevel ($previous)" | ||
309 | $NORMAL | ||
310 | continue | ||
311 | fi | ||
312 | fi | ||
313 | |||
314 | $i stop | ||
315 | error_value=$? | ||
316 | |||
317 | if [ "$error_value" != "0" ] | ||
318 | then | ||
319 | print_error_msg | ||
320 | fi | ||
321 | done | ||
322 | fi | ||
323 | |||
324 | for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null) | ||
325 | do | ||
326 | if [ "$previous" != "N" ] | ||
327 | then | ||
328 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} | ||
329 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix | ||
330 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix | ||
331 | |||
332 | [ -f $prev_start ] && [ ! -f $stop ] && continue | ||
333 | fi | ||
334 | |||
335 | check_script_status | ||
336 | |||
337 | $i start | ||
338 | error_value=$? | ||
339 | |||
340 | if [ "$error_value" != "0" ] | ||
341 | then | ||
342 | print_error_msg | ||
343 | fi | ||
344 | done |
Properties
Name | Value |
---|---|
svn:executable | * |