Magellan Linux

Annotation of /branches/init-0_3_3-r1/magellan-initscripts/etc/rc.d/init.d/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations) (download)
Mon Dec 13 23:24:11 2004 UTC (19 years, 4 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 8222 byte(s)
disabled save of device nodes on livecds; theyy are only ro :)

1 niro 2 #!/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 niro 10 -a ! -e /dev/.devfsd \
216     -a ! -e /.bootdev ]
217 niro 2 then
218     echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
219     cd /dev
220     tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null
221     mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
222     evaluate_retval
223     fi
224     fi
225    
226     if [ "$runlevel" == "6" ]
227     then
228    
229     #load bootsplash
230     splash "rc_init" "${runlevel}"
231    
232     # if requested save devices to a device tarball before halt
233     # only for kernels >=2.6 *and* udev
234     # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
235     if [ "${RC_DEVICE_TARBALL}" = "yes" \
236     -a -e /dev/.udev \
237 niro 10 -a ! -e /dev/.devfsd \
238     -a ! -e /.bootdev ]
239 niro 2 then
240     echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
241     cd /dev
242     tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null
243     mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
244     cd ..
245     evaluate_retval
246     fi
247     fi
248    
249     if [ "$runlevel" = "" ]
250     then
251     echo "Usage: $0 <runlevel>" >&2
252     exit 1
253     fi
254    
255     previous=$PREVLEVEL
256     [ "$previous" = "" ] && previous=N
257    
258     if [ ! -d $rc_base/rc$runlevel.d ]
259     then
260     echo "$rc_base/rc$runlevel.d does not exist"
261     exit 1
262     fi
263    
264     if [ "$previous" != "N" ]
265     then
266     for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null)
267     do
268    
269     check_script_status
270    
271     suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
272     prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
273     sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
274    
275     if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
276     then
277     if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
278     then
279     $WARNING
280     echo "$i can't be executed because it was"
281     echo "not started in the previous runlevel ($previous)"
282     $NORMAL
283     continue
284     fi
285     fi
286    
287     $i stop
288     error_value=$?
289    
290     if [ "$error_value" != "0" ]
291     then
292     print_error_msg
293     fi
294     done
295     fi
296    
297     for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null)
298     do
299     if [ "$previous" != "N" ]
300     then
301     suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
302     stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
303     prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
304    
305     [ -f $prev_start ] && [ ! -f $stop ] && continue
306     fi
307    
308     check_script_status
309    
310     $i start
311     error_value=$?
312    
313     if [ "$error_value" != "0" ]
314     then
315     print_error_msg
316     fi
317     done

Properties

Name Value
svn:executable *