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