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