Magellan Linux

Annotation of /trunk/busybox-initscripts/rc/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 962 - (hide annotations) (download)
Fri Jan 1 11:35:35 2010 UTC (14 years, 4 months ago) by niro
File size: 4300 byte(s)
-updated copyright
1 niro 724 #!/bin/sh
2 niro 783 # $Header: /home/cvsd/magellan-cvs/magellan-src/busybox-initscripts/rc/rc,v 1.2 2008-12-22 22:09:27 niro Exp $
3 niro 724
4     source /etc/conf.d/rc
5     source ${rc_functions}
6    
7     # load udev helper functions
8     source ${rc_base}/init.d/udev
9    
10     # get mage version
11     MAGEVER="$(< /etc/mageversion)"
12    
13     # source kernel config if exists
14     [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
15    
16     trap "" INT QUIT TSTP
17    
18     [[ ! -z $1 ]] && runlevel=$1
19    
20     if [[ -z ${runlevel} ]]
21     then
22     echo "Usage: $0 <runlevel>" >&2
23     exit 1
24     fi
25    
26    
27     if [[ $runlevel = sysinit ]]
28     then
29     echo
30     echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
31 niro 962 echo -e "Copyright 2001-2010 Niels Rogalla; http://magellan-linux.net"
32 niro 724 echo
33    
34     # mount proc filesystem, needed for bootsplash;
35     # no use of '/etc/rc.d/init.d/mountproc' anymore
36     if [ ! -e /proc/mounts ]
37     then
38     echo -e ${COLOREDSTAR}"Mounting proc file system ..."
39     mount -n /proc
40     evaluate_retval
41     fi
42    
43     # set default verbose level for kernel messages
44     [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
45     echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
46    
47     # mount sys file system before udev
48     if [ -d /sys ]
49     then
50     echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
51     mount -n -t sysfs sysfs /sys
52     evaluate_retval
53     else
54     echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
55     echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
56     echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
57     fi
58    
59     #### load udev ####
60     start_udev
61     ## end udev ##
62    
63     ## load devpts ##
64     # devfs/udev with 2.6 has no ptys, so devpts is also needed
65     # check if we really have devpts support
66     if kernel_supports_fs devpts
67     then
68     # /dev/pts maybe not exists.
69     # We only create this directory only if devfs was mounted,
70     # or it will fail as / is still mounted readonly
71     # udev has this dir already, only a sanity check for devfs
72     if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
73     then
74     mkdir -p /dev/pts &> /dev/null || \
75     echo "Could not create /dev/pts !"
76     fi
77    
78     # now mount devpts
79     if [ -d /dev/pts ]
80     then
81     echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
82     mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
83     evaluate_retval
84     fi
85     else
86     # devpts is not supported, give a warning
87     echo -e ${COLRED}"No devpts filesystem found ..."
88     echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
89 niro 783 echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
90 niro 724 echo -e ${COLYELLOW}"or no pty's are available."
91 niro 783 echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
92 niro 724 echo
93     echo -e ${COLYELLOW}"Press any key to continue ..."
94     read
95     fi
96     ## end devpts ##
97    
98    
99     ## load usbfs ##
100     if kernel_supports_fs usbfs
101     then
102     echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..."
103     mount -n -t usbfs usbfs /proc/bus/usb
104     evaluate_retval
105     fi
106     ## end usbfs ##
107    
108     ## services state dir ##
109     echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."
110     mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k
111     evaluate_retval
112    
113     # load bootsplash
114     splash "rc_init" "${runlevel}"
115     fi
116    
117     if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]]
118     then
119     # load bootsplash
120     splash "rc_init" "${runlevel}"
121    
122     # if requested save devices to a device tarball before halt
123     # only for kernels >=2.6 *and* udev
124     # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
125     if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
126     [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
127     then
128     echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
129     ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
130     mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
131     evaluate_retval
132     fi
133    
134     # run through all runlevel scripts
135     for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null)
136     do
137     check_script_status
138     suffix=${i#${rc_base}/rc${runlevel}.d/K[0-9][0-9]}
139    
140     ${i} stop
141     error_value=$?
142    
143     if [[ ${error_value} != 0 ]]
144     then
145     print_error_msg
146     fi
147     done
148     fi
149    
150     if [[ ${runlevel} = sysinit ]] || [[ ${runlevel} = boot ]]
151     then
152     for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
153     do
154     suffix=${i#${rc_base}/rc${runlevel}.d/S[0-9][0-9]}
155     check_script_status
156    
157     ${i} start
158     error_value=$?
159    
160     if [[ ${error_value} != 0 ]]
161     then
162     print_error_msg
163     fi
164     done
165     fi