Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (hide annotations) (download)
Tue Mar 15 19:07:56 2005 UTC (19 years, 2 months ago) by niro
File size: 8370 byte(s)
updated header and fixed whitespaces

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

Properties

Name Value
svn:executable *