Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (hide annotations) (download)
Mon Feb 14 22:26:43 2005 UTC (19 years, 2 months ago) by niro
File size: 8249 byte(s)
mageversion isn't a var anymore; using a file directly

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

Properties

Name Value
svn:executable *