Magellan Linux

Contents of /trunk/initscripts/busybox/rc/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1890 - (show annotations) (download)
Wed Aug 22 17:55:09 2012 UTC (11 years, 8 months ago) by niro
File size: 5558 byte(s)
-honor usr-move
1 #!/bin/sh
2 # $Header: /home/cvsd/magellan-cvs/magellan-src/busybox-initscripts/rc/rc,v 1.2 2008-12-22 22:09:27 niro Exp $
3
4 source /etc/conf.d/rc
5 source ${rc_functions}
6
7 # source kernel config if exists
8 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
9
10 # get mage version
11 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
21 # source kernel config if exists
22 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
23
24 # 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
29 elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
30 then
31 source ${rc_base}/init.d/mdev
32 fi
33
34 trap "" INT QUIT TSTP
35
36 [ "$1" != "" ] && runlevel=$1
37 # export runlevel variable to make it accessible for other rc-scripts
38 export runlevel
39
40 if [[ $runlevel = sysinit ]]
41 then
42 rc_echo
43 rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
44 rc_echo "Copyright 2001-2012 Niels Rogalla; http://magellan-linux.net"
45 rc_echo
46
47 # mount proc filesystem, needed for bootsplash;
48 # no use of '/etc/rc.d/init.d/mountproc' anymore
49 if [ ! -e /proc/mounts ]
50 then
51 rc_print "Mounting proc file system ..."
52 mount -n /proc
53 evaluate_retval
54 fi
55
56 # load bootsplash
57 splash "rc_init" "${runlevel}"
58
59 # set default verbose level for kernel messages
60 [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
61 echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
62
63 # mount sys file system before udev
64 if [ -d /sys ]
65 then
66 if [ ! -e /sys/kernel/notes ]
67 then
68 rc_print "Mounting sysfs file system ..."
69 mount -n -t sysfs sysfs /sys
70 evaluate_retval
71 fi
72 else
73 rc_echo -e ${COLRED}"Fatal: mountpoint /sys missing ..."
74 rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
75 rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
76 fi
77
78 # start device management
79 start_devicemanager
80
81 ## load devpts ##
82 # devfs/udev with 2.6 has no ptys, so devpts is also needed
83 # check if we really have devpts support
84 if kernel_supports_fs devpts
85 then
86 # /dev/pts maybe not exists.
87 # We only create this directory only if devfs was mounted,
88 # or it will fail as / is still mounted readonly
89 # udev has this dir already, only a sanity check for devfs
90 if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
91 then
92 mkdir -p /dev/pts &> /dev/null || \
93 rc_echo "Could not create /dev/pts !"
94 fi
95
96 # now mount devpts
97 if [ -d /dev/pts ]
98 then
99 rc_print "Mounting devpts at /dev/pts ..."
100 mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
101 evaluate_retval
102 fi
103 else
104 # devpts is not supported, give a warning
105 rc_echo -e ${COLRED}"No devpts filesystem found ..."
106 rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
107 rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
108 rc_echo -e ${COLYELLOW}"or no pty's are available."
109 rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
110 rc_echo
111 rc_echo -e ${COLYELLOW}"Press any key to continue ..."
112 read
113 fi
114 ## end devpts ##
115
116
117 ## load usbfs ##
118 if kernel_supports_fs usbfs
119 then
120 rc_print "Mounting usbfs at /proc/bus/usb ..."
121 mount -n -t usbfs usbfs /proc/bus/usb
122 evaluate_retval
123 fi
124 ## end usbfs ##
125
126 ## services state dir ##
127 rc_print "Mounting tmpfs at ${svcdir} ..."
128 mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k
129 evaluate_retval
130
131 ## /run /tmp /var/lock
132 for i in /run /tmp /var/lock
133 do
134 if [ -d ${i} ]
135 then
136 rc_print "Mounting tmpfs at ${i} ..."
137 mount -n -t tmpfs tmpfs ${i} -o rw,nosuid,nodev,relatime
138 evaluate_retval
139 fi
140 done
141 # extra check for /var/lock
142 if [ -L /var/lock ]
143 then
144 mkdir -p /run/lock
145 rc_print "Mounting tmpfs at /run/lock ..."
146 mount -n -t tmpfs tmpfs /run/lock -o rw,nosuid,nodev,relatime
147 evaluate_retval
148 fi
149 # extra check if /run and /var/run are directories
150 if [ -d /run ] && [ -d /var/run ]
151 then
152 rc_print "Mounting tmpfs at /var/run ..."
153 mount -n -o bind /run /var/run
154 evaluate_retval
155 fi
156 fi
157
158 if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]]
159 then
160 # load bootsplash
161 splash "rc_init" "${runlevel}"
162
163 # if requested save devices to a device tarball before halt
164 # only for kernels >=2.6 *and* udev
165 # make sure that udev is mounted but *not* devfs --> /dev/.devfsd
166 if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
167 [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
168 then
169 rc_print "Saving /dev device nodes ..."
170 ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
171 mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
172 evaluate_retval
173 fi
174
175 # stop device management
176 stop_devicemanager
177
178 # run through all runlevel scripts
179 for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null)
180 do
181 check_script_status
182 suffix=${i#${rc_base}/rc${runlevel}.d/K[0-9][0-9]}
183
184 ${i} stop
185 error_value=$?
186
187 if [[ ${error_value} != 0 ]]
188 then
189 print_error_msg
190 fi
191 done
192 fi
193
194 if [[ ${runlevel} = sysinit ]] || [[ ${runlevel} = boot ]]
195 then
196 for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
197 do
198 suffix=${i#${rc_base}/rc${runlevel}.d/S[0-9][0-9]}
199 check_script_status
200
201 ${i} start
202 error_value=$?
203
204 if [[ ${error_value} != 0 ]]
205 then
206 print_error_msg
207 fi
208 done
209 fi
210
211 if [[ ${runlevel} = boot ]] || [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]]
212 then
213 # exit bootsplash
214 splash "rc_exit" "${runlevel}"
215 fi