Magellan Linux

Contents of /trunk/magellan-initscripts/etc/rc.d/init.d/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 781 - (show annotations) (download)
Mon Dec 22 22:01:15 2008 UTC (15 years, 4 months ago) by niro
File size: 8584 byte(s)
-use /etc/conf.d/rc instead of /etc/sysconfig/rc

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

Properties

Name Value
svn:executable *