Contents of /trunk/magellan-initscripts/rc/rc
Parent Directory | Revision Log
Revision 1248 -
(show annotations)
(download)
Fri Mar 11 17:18:42 2011 UTC (13 years, 6 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 5052 byte(s)
Fri Mar 11 17:18:42 2011 UTC (13 years, 6 months ago) by niro
Original Path: trunk/magellan-initscripts/etc/rc.d/init.d/rc
File size: 5052 byte(s)
-use rc_print and rc_echo
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | source /etc/conf.d/rc |
5 | source ${rc_functions} |
6 | |
7 | # get mage version |
8 | MAGEVER="$(< /etc/mageversion)" |
9 | |
10 | # source kernel config if exists |
11 | [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
12 | |
13 | # override devicemanager helper functions |
14 | if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]] |
15 | then |
16 | source ${rc_base}/init.d/udev |
17 | |
18 | elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]] |
19 | then |
20 | source ${rc_base}/init.d/mdev |
21 | fi |
22 | |
23 | trap "" INT QUIT TSTP |
24 | |
25 | [ "$1" != "" ] && runlevel=$1 |
26 | |
27 | if [[ $runlevel = sysinit ]] |
28 | then |
29 | rc_echo |
30 | rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
31 | rc_echo "Copyright 2001-2011 Niels Rogalla; http://magellan-linux.net" |
32 | rc_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 | rc_print "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 | rc_print "Mounting sysfs file system ..." |
51 | mount -n -t sysfs sysfs /sys |
52 | evaluate_retval |
53 | else |
54 | rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." |
55 | rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
56 | rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
57 | fi |
58 | |
59 | # start device management |
60 | start_devicemanager |
61 | |
62 | ## load devpts ## |
63 | # devfs/udev with 2.6 has no ptys, so devpts is also needed |
64 | # check if we really have devpts support |
65 | if kernel_supports_fs devpts |
66 | then |
67 | # /dev/pts maybe not exists. |
68 | # We only create this directory only if devfs was mounted, |
69 | # or it will fail as / is still mounted readonly |
70 | # udev has this dir already, only a sanity check for devfs |
71 | if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
72 | then |
73 | mkdir -p /dev/pts &> /dev/null || \ |
74 | rc_echo "Could not create /dev/pts !" |
75 | fi |
76 | |
77 | # now mount devpts |
78 | if [ -d /dev/pts ] |
79 | then |
80 | rc_print "Mounting devpts at /dev/pts ..." |
81 | mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
82 | evaluate_retval |
83 | fi |
84 | else |
85 | # devpts is not supported, give a warning |
86 | rc_echo -e ${COLRED}"No devpts filesystem found ..." |
87 | rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
88 | rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
89 | rc_echo -e ${COLYELLOW}"or no pty's are available." |
90 | rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
91 | rc_echo |
92 | rc_echo -e ${COLYELLOW}"Press any key to continue ..." |
93 | read |
94 | fi |
95 | ## end devpts ## |
96 | |
97 | |
98 | ## load usbfs ## |
99 | if kernel_supports_fs usbfs |
100 | then |
101 | rc_print "Mounting usbfs at /proc/bus/usb ..." |
102 | mount -n -t usbfs usbfs /proc/bus/usb |
103 | evaluate_retval |
104 | fi |
105 | ## end usbfs ## |
106 | |
107 | ## services state dir ## |
108 | rc_print "Mounting tmpfs at ${svcdir} ..." |
109 | mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k |
110 | evaluate_retval |
111 | |
112 | # load bootsplash |
113 | splash "rc_init" "${runlevel}" |
114 | fi |
115 | |
116 | |
117 | if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] |
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 | rc_print "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 | # stop device management |
135 | stop_devicemanager |
136 | fi |
137 | |
138 | |
139 | if [ "$runlevel" = "" ] |
140 | then |
141 | rc_echo "Usage: $0 <runlevel>" >&2 |
142 | exit 1 |
143 | fi |
144 | |
145 | |
146 | previous=$PREVLEVEL |
147 | [ "$previous" = "" ] && previous=N |
148 | |
149 | if [ ! -d $rc_base/rc$runlevel.d ] |
150 | then |
151 | rc_echo "$rc_base/rc$runlevel.d does not exist" |
152 | exit 1 |
153 | fi |
154 | |
155 | if [ "$previous" != "N" ] |
156 | then |
157 | for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null) |
158 | do |
159 | |
160 | check_script_status |
161 | |
162 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} |
163 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
164 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix |
165 | |
166 | if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ] |
167 | then |
168 | if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] |
169 | then |
170 | $WARNING |
171 | rc_echo "$i can't be executed because it was" |
172 | rc_echo "not started in the previous runlevel ($previous)" |
173 | $NORMAL |
174 | continue |
175 | fi |
176 | fi |
177 | |
178 | $i stop |
179 | error_value=$? |
180 | |
181 | if [ "$error_value" != "0" ] |
182 | then |
183 | print_error_msg |
184 | fi |
185 | done |
186 | fi |
187 | |
188 | for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null) |
189 | do |
190 | if [ "$previous" != "N" ] |
191 | then |
192 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} |
193 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix |
194 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
195 | |
196 | [ -f $prev_start ] && [ ! -f $stop ] && continue |
197 | fi |
198 | |
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 |
Properties
Name | Value |
---|---|
svn:executable | * |