Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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