Contents of /trunk/initscripts/sysvinit/rc/rc
Parent Directory | Revision Log
Revision 2304 -
(show annotations)
(download)
Thu Jan 2 13:26:56 2014 UTC (10 years, 8 months ago) by niro
File size: 5846 byte(s)
Thu Jan 2 13:26:56 2014 UTC (10 years, 8 months ago) by niro
File size: 5846 byte(s)
-updated copyright for 2014
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | source /etc/conf.d/rc |
5 | source ${rc_functions} |
6 | |
7 | # get mage version |
8 | if [[ -f /etc/os-release ]] |
9 | then |
10 | MAGEVER="$(read_os_release version_id)" |
11 | elif [ -f /etc/mageversion ] |
12 | then |
13 | MAGEVER="$(< /etc/mageversion)" |
14 | else |
15 | MAGEVER="unkown" |
16 | fi |
17 | |
18 | # source kernel config if exists |
19 | [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel |
20 | |
21 | # override devicemanager helper functions |
22 | if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]] |
23 | then |
24 | source ${rc_base}/init.d/udev |
25 | |
26 | elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]] |
27 | then |
28 | source ${rc_base}/init.d/mdev |
29 | fi |
30 | |
31 | trap "" INT QUIT TSTP |
32 | |
33 | [ "$1" != "" ] && runlevel=$1 |
34 | |
35 | if [[ $runlevel = sysinit ]] |
36 | then |
37 | rc_echo |
38 | rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" |
39 | rc_echo "Copyright 2001-2014 Niels Rogalla; http://magellan-linux.net" |
40 | rc_echo |
41 | |
42 | # mount proc filesystem, needed for bootsplash; |
43 | # no use of '/etc/rc.d/init.d/mountproc' anymore |
44 | if [ ! -e /proc/mounts ] |
45 | then |
46 | rc_print "Mounting proc file system ..." |
47 | mount -n /proc |
48 | evaluate_retval |
49 | fi |
50 | |
51 | # set default verbose level for kernel messages |
52 | [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 |
53 | echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk |
54 | |
55 | # mount sys file system before udev |
56 | if [ -d /sys ] |
57 | then |
58 | if [ ! -e /sys/kernel/notes ] |
59 | then |
60 | rc_print "Mounting sysfs file system ..." |
61 | mount -n -t sysfs sysfs /sys |
62 | evaluate_retval |
63 | fi |
64 | else |
65 | rc_echo -e ${COLRED}"Fatal: mountpoint /sys missing ..." |
66 | rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." |
67 | rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." |
68 | fi |
69 | |
70 | # start device management |
71 | start_devicemanager |
72 | |
73 | ## load devpts ## |
74 | # devfs/udev with 2.6 has no ptys, so devpts is also needed |
75 | # check if we really have devpts support |
76 | if kernel_supports_fs devpts |
77 | then |
78 | # /dev/pts maybe not exists. |
79 | # We only create this directory only if devfs was mounted, |
80 | # or it will fail as / is still mounted readonly |
81 | # udev has this dir already, only a sanity check for devfs |
82 | if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs |
83 | then |
84 | mkdir -p /dev/pts &> /dev/null || \ |
85 | rc_echo "Could not create /dev/pts !" |
86 | fi |
87 | |
88 | # now mount devpts |
89 | if [ -d /dev/pts ] |
90 | then |
91 | rc_print "Mounting devpts at /dev/pts ..." |
92 | mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts |
93 | evaluate_retval |
94 | fi |
95 | else |
96 | # devpts is not supported, give a warning |
97 | rc_echo -e ${COLRED}"No devpts filesystem found ..." |
98 | rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." |
99 | rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," |
100 | rc_echo -e ${COLYELLOW}"or no pty's are available." |
101 | rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." |
102 | rc_echo |
103 | rc_echo -e ${COLYELLOW}"Press any key to continue ..." |
104 | read |
105 | fi |
106 | ## end devpts ## |
107 | |
108 | |
109 | ## load usbfs ## |
110 | if kernel_supports_fs usbfs |
111 | then |
112 | rc_print "Mounting usbfs at /proc/bus/usb ..." |
113 | mount -n -t usbfs usbfs /proc/bus/usb |
114 | evaluate_retval |
115 | fi |
116 | ## end usbfs ## |
117 | |
118 | ## services state dir ## |
119 | rc_print "Mounting tmpfs at ${svcdir} ..." |
120 | mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k |
121 | evaluate_retval |
122 | |
123 | ## /run /tmp /var/lock |
124 | for i in /run /tmp /var/lock |
125 | do |
126 | if [ -d ${i} ] |
127 | then |
128 | rc_print "Mounting tmpfs at ${i} ..." |
129 | mount -n -t tmpfs tmpfs ${i} -o rw,nosuid,nodev,relatime |
130 | evaluate_retval |
131 | fi |
132 | done |
133 | # extra check for /var/lock |
134 | if [ -L /var/lock ] |
135 | then |
136 | mkdir -p /run/lock |
137 | rc_print "Mounting tmpfs at /run/lock ..." |
138 | mount -n -t tmpfs tmpfs /run/lock -o rw,nosuid,nodev,relatime |
139 | evaluate_retval |
140 | fi |
141 | # extra check if /run and /var/run are directories |
142 | if [ -d /run ] && [ -d /var/run ] |
143 | then |
144 | rc_print "Mounting tmpfs at /var/run ..." |
145 | mount -n -o bind /run /var/run |
146 | evaluate_retval |
147 | fi |
148 | |
149 | # load bootsplash |
150 | splash "rc_init" "${runlevel}" |
151 | fi |
152 | |
153 | |
154 | if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] |
155 | then |
156 | # load bootsplash |
157 | splash "rc_init" "${runlevel}" |
158 | |
159 | # if requested save devices to a device tarball before halt |
160 | # only for kernels >=2.6 *and* udev |
161 | # make sure that udev is mounted but *not* devfs --> /dev/.devfsd |
162 | if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ |
163 | [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] |
164 | then |
165 | rc_print "Saving /dev device nodes ..." |
166 | ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) |
167 | mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 |
168 | evaluate_retval |
169 | fi |
170 | |
171 | # stop device management |
172 | stop_devicemanager |
173 | fi |
174 | |
175 | |
176 | if [ "$runlevel" = "" ] |
177 | then |
178 | rc_echo "Usage: $0 <runlevel>" >&2 |
179 | exit 1 |
180 | fi |
181 | |
182 | |
183 | previous=$PREVLEVEL |
184 | [ "$previous" = "" ] && previous=N |
185 | |
186 | if [ ! -d $rc_base/rc$runlevel.d ] |
187 | then |
188 | rc_echo "$rc_base/rc$runlevel.d does not exist" |
189 | exit 1 |
190 | fi |
191 | |
192 | if [ "$previous" != "N" ] |
193 | then |
194 | for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null) |
195 | do |
196 | |
197 | check_script_status |
198 | |
199 | suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]} |
200 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
201 | sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix |
202 | |
203 | if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ] |
204 | then |
205 | if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] |
206 | then |
207 | $WARNING |
208 | rc_echo "$i can't be executed because it was" |
209 | rc_echo "not started in the previous runlevel ($previous)" |
210 | $NORMAL |
211 | continue |
212 | fi |
213 | fi |
214 | |
215 | $i stop |
216 | error_value=$? |
217 | |
218 | if [ "$error_value" != "0" ] |
219 | then |
220 | print_error_msg |
221 | fi |
222 | done |
223 | fi |
224 | |
225 | for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null) |
226 | do |
227 | if [ "$previous" != "N" ] |
228 | then |
229 | suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} |
230 | stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix |
231 | prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix |
232 | |
233 | [ -f $prev_start ] && [ ! -f $stop ] && continue |
234 | fi |
235 | |
236 | check_script_status |
237 | |
238 | $i start |
239 | error_value=$? |
240 | |
241 | if [ "$error_value" != "0" ] |
242 | then |
243 | print_error_msg |
244 | fi |
245 | done |
Properties
Name | Value |
---|---|
svn:executable | * |