1 | #!/bin/bash |
---|
2 | # |
---|
3 | # /etc/rc.sysinit - run once at boot time |
---|
4 | # |
---|
5 | # Taken in part from Miquel van Smoorenburg's bcheckrc. |
---|
6 | # |
---|
7 | |
---|
8 | # Set the path |
---|
9 | PATH=/bin:/sbin:/usr/bin:/usr/sbin |
---|
10 | export PATH |
---|
11 | |
---|
12 | HOSTNAME=`/bin/hostname` |
---|
13 | HOSTTYPE=`uname -m` |
---|
14 | KERNELRELEASE=`uname -r` |
---|
15 | KERNELVERSION=`echo $KERNELRELEASE | cut -f 1-2 -d.` |
---|
16 | |
---|
17 | # VLEE: make host dependent /etc |
---|
18 | if [ -x /etc/rc.diskless ]; then |
---|
19 | echo -n "Preparing diskless setup :" |
---|
20 | if /etc/rc.diskless ; then |
---|
21 | echo " [ OK ]" |
---|
22 | else |
---|
23 | echo " [ NG ]" |
---|
24 | fi |
---|
25 | elif [ -x /DLKit/etc/rc.diskless ]; then |
---|
26 | echo -n "Preparing diskless setup :" |
---|
27 | if /DLKit/etc/rc.diskless ; then |
---|
28 | echo " [ OK ]" |
---|
29 | else |
---|
30 | echo " [ NG ]" |
---|
31 | fi |
---|
32 | fi |
---|
33 | |
---|
34 | # Read in config data. |
---|
35 | if [ -f /etc/sysconfig/network ]; then |
---|
36 | . /etc/sysconfig/network |
---|
37 | else |
---|
38 | NETWORKING=no |
---|
39 | fi |
---|
40 | |
---|
41 | if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then |
---|
42 | HOSTNAME=localhost |
---|
43 | fi |
---|
44 | |
---|
45 | # Mount /proc, /sys |
---|
46 | if [ ! -e /proc/mounts ]; then |
---|
47 | mount -n -t proc /proc /proc |
---|
48 | mount -n -t sysfs /sys /sys >/dev/null 2>&1 |
---|
49 | fi |
---|
50 | if [ ! -d /proc/bus/usb ]; then |
---|
51 | modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
---|
52 | else |
---|
53 | mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
---|
54 | fi |
---|
55 | |
---|
56 | # readahead |
---|
57 | if [ -f /.readahead_collect -a -r /etc/sysconfig/readahead ]; then |
---|
58 | . /etc/sysconfig/readahead |
---|
59 | if [ "x$READAHEAD_COLLECT" == "xyes" -a ! -f /forcefsck -a -x /sbin/readahead-collector ]; then |
---|
60 | /sbin/readahead-collector |
---|
61 | fi |
---|
62 | elif [ -x /sbin/readahead_early ]; then |
---|
63 | /sbin/readahead_early & |
---|
64 | fi |
---|
65 | |
---|
66 | if [ -x /etc/rc.early.local ]; then |
---|
67 | . /etc/rc.early.local |
---|
68 | fi |
---|
69 | |
---|
70 | # Source functions |
---|
71 | . /etc/init.d/functions |
---|
72 | |
---|
73 | PLYMOUTH= |
---|
74 | [ -x /usr/bin/plymouth ] && PLYMOUTH=yes |
---|
75 | |
---|
76 | # Print a banner. ;) |
---|
77 | echo -en $"\t\t\tWelcome to " |
---|
78 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[1;36m" |
---|
79 | echo -en $"Vine" |
---|
80 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[0;39m" |
---|
81 | echo $" Linux" |
---|
82 | if [ "$PROMPT" != "no" ]; then |
---|
83 | echo -en $"\t\tPress 'I' to enter interactive startup." |
---|
84 | echo |
---|
85 | fi |
---|
86 | |
---|
87 | # Fix console loglevel |
---|
88 | /bin/dmesg -n $LOGLEVEL |
---|
89 | |
---|
90 | # read /proc/cmdline once |
---|
91 | cmdline=$(cat /proc/cmdline) |
---|
92 | |
---|
93 | # initialize splash |
---|
94 | initsplash 5 |
---|
95 | rc_splash start 1 |
---|
96 | |
---|
97 | # Initialize hardware |
---|
98 | if [ -f /proc/sys/kernel/modprobe ]; then |
---|
99 | if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then |
---|
100 | sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 |
---|
101 | else |
---|
102 | sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1 |
---|
103 | fi |
---|
104 | fi |
---|
105 | |
---|
106 | # kill nash and start udev |
---|
107 | nashpid=$(pidof nash 2>/dev/null) |
---|
108 | [ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1 |
---|
109 | unset nashpid |
---|
110 | /sbin/start_udev |
---|
111 | |
---|
112 | # Load user-defined modules |
---|
113 | for file in /etc/sysconfig/modules/*.modules ; do |
---|
114 | [ -x $file ] && $file |
---|
115 | done |
---|
116 | |
---|
117 | # Load modules (for backward compatibility with VARs) |
---|
118 | if [ -f /etc/rc.modules ]; then |
---|
119 | /etc/rc.modules |
---|
120 | fi |
---|
121 | |
---|
122 | # VLEE: make and mount /dev |
---|
123 | if [ -x /etc/rc.MAKEDEV ]; then |
---|
124 | action $"Making and Mounting /dev filesystem: " /etc/rc.MAKEDEV |
---|
125 | elif [ -x /DLKit/etc/rc.MAKEDEV ]; then |
---|
126 | action $"Making and Mounting /dev filesystem: " /DLKit/etc/rc.MAKEDEV |
---|
127 | fi |
---|
128 | |
---|
129 | # Unmount the initrd, if necessary |
---|
130 | if grep -q /initrd /proc/mounts && ! grep -q /initrd/loopfs /proc/mounts ; then |
---|
131 | action $"Unmounting initrd: " umount /initrd |
---|
132 | /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 |
---|
133 | fi |
---|
134 | |
---|
135 | # load SCSI modules |
---|
136 | for module in `/sbin/modprobe -c | LC_ALL=C awk '/^alias[[:space:]]+scsi_hostadapter[0-9]*[[:space:]]/ { print $3 }'` |
---|
137 | do |
---|
138 | action $"Loading SCSI module ($module): " /sbin/modprobe $module |
---|
139 | done |
---|
140 | |
---|
141 | # Configure kernel parameters |
---|
142 | update_boot_stage RCkernelparam |
---|
143 | action $"Configuring kernel parameters: " sysctl -e -p /etc/sysctl.conf |
---|
144 | |
---|
145 | # Set the system clock. |
---|
146 | ARC=0 |
---|
147 | SRM=0 |
---|
148 | UTC=0 |
---|
149 | |
---|
150 | if [ -f /etc/sysconfig/clock ]; then |
---|
151 | . /etc/sysconfig/clock |
---|
152 | |
---|
153 | # convert old style clock config to new values |
---|
154 | if [ "${CLOCKMODE}" = "GMT" ]; then |
---|
155 | UTC=true |
---|
156 | elif [ "${CLOCKMODE}" = "ARC" ]; then |
---|
157 | ARC=true |
---|
158 | fi |
---|
159 | fi |
---|
160 | |
---|
161 | CLOCKDEF="" |
---|
162 | CLOCKFLAGS="$CLOCKFLAGS --hctosys" |
---|
163 | |
---|
164 | case "$UTC" in |
---|
165 | yes|true) |
---|
166 | CLOCKFLAGS="$CLOCKFLAGS --utc"; |
---|
167 | CLOCKDEF="$CLOCKDEF (utc)"; |
---|
168 | ;; |
---|
169 | no|false) |
---|
170 | CLOCKFLAGS="$CLOCKFLAGS --localtime"; |
---|
171 | CLOCKDEF="$CLOCKDEF (localtime)"; |
---|
172 | ;; |
---|
173 | esac |
---|
174 | |
---|
175 | case "$ARC" in |
---|
176 | yes|true) |
---|
177 | CLOCKFLAGS="$CLOCKFLAGS --arc"; |
---|
178 | CLOCKDEF="$CLOCKDEF (arc)"; |
---|
179 | ;; |
---|
180 | esac |
---|
181 | case "$SRM" in |
---|
182 | yes|true) |
---|
183 | CLOCKFLAGS="$CLOCKFLAGS --srm"; |
---|
184 | CLOCKDEF="$CLOCKDEF (srm)"; |
---|
185 | ;; |
---|
186 | esac |
---|
187 | |
---|
188 | /sbin/hwclock $CLOCKFLAGS |
---|
189 | |
---|
190 | action $"Setting clock $CLOCKDEF: `date`" date |
---|
191 | |
---|
192 | if [ "`/sbin/consoletype`" = "vt" ]; then |
---|
193 | # Load keymap |
---|
194 | if [ -x /bin/loadkeys ]; then |
---|
195 | KEYTABLE= |
---|
196 | KEYMAP= |
---|
197 | if [ -f /etc/sysconfig/console/default.kmap ]; then |
---|
198 | KEYMAP=/etc/sysconfig/console/default.kmap |
---|
199 | else |
---|
200 | if [ -f /etc/sysconfig/keyboard ]; then |
---|
201 | . /etc/sysconfig/keyboard |
---|
202 | fi |
---|
203 | if [ -n "$KEYTABLE" -a -d "/lib/kbd/keymaps" ]; then |
---|
204 | KEYMAP=$KEYTABLE |
---|
205 | fi |
---|
206 | fi |
---|
207 | if [ -n "$KEYMAP" ]; then |
---|
208 | # Since this takes in/output from stdin/out, we can't use initlog |
---|
209 | if [ -n "$KEYTABLE" ]; then |
---|
210 | echo -n $"Loading default keymap ($KEYTABLE): " |
---|
211 | else |
---|
212 | echo -n $"Loading default keymap: " |
---|
213 | fi |
---|
214 | loadkeys $KEYMAP < /dev/tty0 > /dev/tty0 2>/dev/null && \ |
---|
215 | success $"Loading default keymap" || failure $"Loading default keymap" |
---|
216 | echo |
---|
217 | fi |
---|
218 | fi |
---|
219 | fi |
---|
220 | |
---|
221 | # Start up swapping. |
---|
222 | action $"Activating swap partitions: " swapon -a -e |
---|
223 | |
---|
224 | # Set the hostname. |
---|
225 | update_boot_stage RChostname |
---|
226 | action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
---|
227 | |
---|
228 | #echo "raidautorun /dev/md0" | nash --quiet |
---|
229 | [ -f /etc/mdadm.conf -a -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run |
---|
230 | |
---|
231 | # LVM2 initialization |
---|
232 | if [ -x /sbin/lvm -o -x /sbin/multipath.static -o -x /sbin/dmraid.static ]; then |
---|
233 | if ! LC_ALL=C fgrep -q "device-mapper" /proc/devices 2>/dev/null ; then |
---|
234 | modprobe dm-mod >/dev/null 2>&1 |
---|
235 | fi |
---|
236 | #echo "mkdmnod" | /sbin/nash --quiet >/dev/null 2>&1 |
---|
237 | fi |
---|
238 | |
---|
239 | if [ -c /dev/mapper/control ]; then |
---|
240 | if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf -a -x /sbin/multipath.static ]; then |
---|
241 | modprobe dm-multipath >/dev/null 2>&1 |
---|
242 | /sbin/multipath.static -v 0 |
---|
243 | if [ -x /sbin/kpartx ]; then |
---|
244 | /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a" |
---|
245 | fi |
---|
246 | fi |
---|
247 | |
---|
248 | if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid.static ]; then |
---|
249 | modprobe dm-mirror > /dev/null 2>&1 |
---|
250 | /sbin/dmraid.static -i -ay |
---|
251 | fi |
---|
252 | |
---|
253 | if [ -x /sbin/lvm ]; then |
---|
254 | if /sbin/lvm vgscan --mknodes --ignorelockingfailure > /dev/null 2>&1 ; then |
---|
255 | action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --ignorelockingfailure |
---|
256 | fi |
---|
257 | fi |
---|
258 | fi |
---|
259 | |
---|
260 | update_boot_stage RCfsck |
---|
261 | |
---|
262 | if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then |
---|
263 | fastboot=yes |
---|
264 | else |
---|
265 | fastboot= |
---|
266 | fi |
---|
267 | |
---|
268 | if [ -f /fsckoptions ]; then |
---|
269 | fsckoptions=`cat /fsckoptions` |
---|
270 | else |
---|
271 | fsckoptions= |
---|
272 | fi |
---|
273 | |
---|
274 | READONLY= |
---|
275 | if [ -f /etc/sysconfig/readonly-root ]; then |
---|
276 | . /etc/sysconfig/readonly-root |
---|
277 | fi |
---|
278 | if strstr "$cmdline" readonlyroot ; then |
---|
279 | READONLY=yes |
---|
280 | fi |
---|
281 | if strstr "$cmdline" noreadonlyroot ; then |
---|
282 | READONLY=no |
---|
283 | fi |
---|
284 | |
---|
285 | |
---|
286 | if [ -f /forcefsck ]; then |
---|
287 | fsckoptions="-f $fsckoptions" |
---|
288 | elif [ -f /.autofsck ]; then |
---|
289 | echo $"Your system appears to have shut down uncleanly" |
---|
290 | AUTOFSCK_TIMEOUT=5 |
---|
291 | AUTOFSCK_DEF_CHECK=no |
---|
292 | [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck |
---|
293 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
294 | AUTOFSCK_OPT=-f |
---|
295 | else |
---|
296 | AUTOFSCK_OPT= |
---|
297 | fi |
---|
298 | |
---|
299 | if [ "$PROMPT" != "no" ]; then |
---|
300 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
301 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press N within %d seconds to not force file system integrity check..." n ; then |
---|
302 | AUTOFSCK_OPT= |
---|
303 | fi |
---|
304 | else |
---|
305 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press Y within %d seconds to force file system integrity check..." y ; then |
---|
306 | AUTOFSCK_OPT=-f |
---|
307 | fi |
---|
308 | fi |
---|
309 | echo |
---|
310 | else |
---|
311 | # PROMPT not allowed |
---|
312 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
313 | echo $"Forcing file system integrity check due to default setting" |
---|
314 | else |
---|
315 | echo $"Not forcing file system integrity check due to default setting" |
---|
316 | fi |
---|
317 | fi |
---|
318 | fsckoptions="$AUTOFSCK_OPT $fsckoptions" |
---|
319 | fi |
---|
320 | |
---|
321 | if [ "$BOOTUP" != "serial" ]; then |
---|
322 | fsckoptions="-C $fsckoptions" |
---|
323 | else |
---|
324 | fsckoptions="-V $fsckoptions" |
---|
325 | fi |
---|
326 | |
---|
327 | _RUN_QUOTACHECK=0 |
---|
328 | ROOTFSTYPE=`grep " / " /proc/mounts | awk '{ print $3 }'` |
---|
329 | if [ -z "$fastboot" -a "$READONLY" != "yes" -a "$ROOTFSTYPE" != "nfs" -a "$ROOTFSTYPE" != "reiserfs" -a "$ROOTFSTYPE" != "unionfs" -a "$ROOTFSTYPE" != "squashfs" ]; then |
---|
330 | |
---|
331 | STRING=$"Checking root filesystem" |
---|
332 | echo $STRING |
---|
333 | initlog -c "fsck -T -a $fsckoptions /" |
---|
334 | rc=$? |
---|
335 | |
---|
336 | if [ "$rc" = "0" ]; then |
---|
337 | success "$STRING" |
---|
338 | echo |
---|
339 | elif [ "$rc" = "1" ]; then |
---|
340 | passed $"$STRING" |
---|
341 | echo |
---|
342 | fi |
---|
343 | |
---|
344 | # A return of 2 or higher means there were serious problems. |
---|
345 | if [ $rc -gt 1 ]; then |
---|
346 | [ -n "$PLYMOUTH" ] && plymouth --hide-splash |
---|
347 | |
---|
348 | failure "$STRING" |
---|
349 | echo |
---|
350 | echo |
---|
351 | echo $"*** An error occurred during the file system check." |
---|
352 | echo $"*** Dropping you to a shell; the system will reboot" |
---|
353 | echo $"*** when you leave the shell." |
---|
354 | |
---|
355 | PS1=$"(Repair filesystem) \# # "; export PS1 |
---|
356 | sulogin |
---|
357 | |
---|
358 | echo $"Unmounting file systems" |
---|
359 | umount -a |
---|
360 | mount -n -o remount,ro / |
---|
361 | echo $"Automatic reboot in progress." |
---|
362 | reboot -f |
---|
363 | elif [ "$rc" = "1" ]; then |
---|
364 | _RUN_QUOTACHECK=1 |
---|
365 | fi |
---|
366 | fi |
---|
367 | |
---|
368 | update_boot_stage RCquotacheck |
---|
369 | |
---|
370 | # Possibly update quotas if fsck was run on /. |
---|
371 | grep -E '[[:space:]]+/[[:space:]]+' /etc/fstab | \ |
---|
372 | awk '{ print $4 }' | \ |
---|
373 | grep -q quota |
---|
374 | _ROOT_HAS_QUOTA=$? |
---|
375 | if [ X"$_RUN_QUOTACHECK" = X1 -a \ |
---|
376 | "$_ROOT_HAS_QUOTA" -a \ |
---|
377 | -x /sbin/quotacheck ]; then |
---|
378 | if [ -x /sbin/convertquota ]; then |
---|
379 | if [ -f /quota.user ]; then |
---|
380 | action $"Converting old user quota files: " \ |
---|
381 | /sbin/convertquota -u / && rm -f /quota.user |
---|
382 | fi |
---|
383 | if [ -f /quota.group ]; then |
---|
384 | action $"Converting old group quota files: " \ |
---|
385 | /sbin/convertquota -g / && rm -f /quota.group |
---|
386 | fi |
---|
387 | fi |
---|
388 | action $"Checking root filesystem quotas: " /sbin/quotacheck -nug / |
---|
389 | fi |
---|
390 | |
---|
391 | # check for arguments passed from kernel |
---|
392 | |
---|
393 | update_boot_stage RCmountfs |
---|
394 | |
---|
395 | # Remount the root filesystem in specified mode |
---|
396 | state=`awk '/(^\/dev\/root| \/ )/ { print $4 }' /proc/mounts` |
---|
397 | newstate=`awk '/^#/{next} $2 == "/" {print $4 }' /etc/fstab` |
---|
398 | if strstr "$cmdline" no_remount_rootfs ;then |
---|
399 | action $"Staying readonly root filesystem mode : " /bin/true |
---|
400 | else |
---|
401 | [ "$state" != "rw" ] && \ |
---|
402 | action $"Remounting root filesystem in specified mode($newstate): " mount -n -o remount,$newstate / |
---|
403 | fi |
---|
404 | |
---|
405 | # Clear mtab |
---|
406 | (>/etc/mtab) &> /dev/null |
---|
407 | |
---|
408 | # Remove stale backups |
---|
409 | rm -f /etc/mtab~ /etc/mtab~~ |
---|
410 | |
---|
411 | # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab. |
---|
412 | mount -f / |
---|
413 | mount -f /proc |
---|
414 | [ -f /proc/bus/usb/devices ] && mount -f -t usbfs none /proc/bus/usb |
---|
415 | [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev |
---|
416 | if [ -f /proc/filesystems -a -d /sys ] ; then |
---|
417 | if grep -q sysfs /proc/filesystems ; then |
---|
418 | mount -f -t sysfs none /sys |
---|
419 | fi |
---|
420 | fi |
---|
421 | |
---|
422 | if strstr "$cmdline" hdparm ;then |
---|
423 | update_boot_stage RChdparm |
---|
424 | |
---|
425 | # Turn on harddisk optimization |
---|
426 | # There is only one file /etc/sysconfig/harddisks for all disks |
---|
427 | # after installing the hdparm-RPM. If you need different hdparm parameters |
---|
428 | # for each of your disks, copy /etc/sysconfig/harddisks to |
---|
429 | # /etc/sysconfig/harddiskhda (hdb, hdc...) and modify it. |
---|
430 | # each disk which has no special parameters will use the defaults. |
---|
431 | |
---|
432 | disk[0]=s; disk[1]=hda; disk[2]=hdb; disk[3]=hdc; |
---|
433 | disk[4]=hdd; disk[5]=hde; disk[6]=hdf; disk[7]=hdg; disk[8]=hdh; |
---|
434 | |
---|
435 | |
---|
436 | if [ -x /sbin/hdparm ]; then |
---|
437 | for device in 0 1 2 3 4 5 6 7 8; do |
---|
438 | unset MULTIPLE_IO USE_DMA EIDE_32BIT LOOKAHEAD EXTRA_PARAMS |
---|
439 | if [ -f /etc/sysconfig/harddisk${disk[$device]} ]; then |
---|
440 | . /etc/sysconfig/harddisk${disk[$device]} |
---|
441 | HDFLAGS[$device]= |
---|
442 | if [ -n "$MULTIPLE_IO" ]; then |
---|
443 | HDFLAGS[$device]="-q -m$MULTIPLE_IO" |
---|
444 | fi |
---|
445 | if [ -n "$USE_DMA" ]; then |
---|
446 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -d$USE_DMA" |
---|
447 | fi |
---|
448 | if [ -n "$EIDE_32BIT" ]; then |
---|
449 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -c$EIDE_32BIT" |
---|
450 | fi |
---|
451 | if [ -n "$LOOKAHEAD" ]; then |
---|
452 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -A$LOOKAHEAD" |
---|
453 | fi |
---|
454 | if [ -n "$EXTRA_PARAMS" ]; then |
---|
455 | HDFLAGS[$device]="${HDFLAGS[$device]} $EXTRA_PARAMS" |
---|
456 | fi |
---|
457 | else |
---|
458 | HDFLAGS[$device]="${HDFLAGS[0]}" |
---|
459 | fi |
---|
460 | if [ -e "/proc/ide/${disk[$device]}/media" ] ; then |
---|
461 | hdmedia=`cat /proc/ide/${disk[$device]}/media` |
---|
462 | if [ "$hdmedia" = "disk" ]; then |
---|
463 | if [ -n "${HDFLAGS[$device]}" ]; then |
---|
464 | action $"Setting hard drive parameters for ${disk[$device]}: " /sbin/hdparm ${HDFLAGS[$device]} /dev/${disk[$device]} |
---|
465 | fi |
---|
466 | fi |
---|
467 | fi |
---|
468 | done |
---|
469 | fi |
---|
470 | fi |
---|
471 | |
---|
472 | # The root filesystem is now read-write, so we can now log via syslog() directly.. |
---|
473 | if [ -n "$IN_INITLOG" ]; then |
---|
474 | IN_INITLOG= |
---|
475 | fi |
---|
476 | |
---|
477 | update_boot_stage RCmd |
---|
478 | |
---|
479 | if [ -f /etc/mdadm.conf ]; then |
---|
480 | /sbin/mdadm -A -s |
---|
481 | # LVM2 initialization, take 2 |
---|
482 | if [ -c /dev/mapper/control ]; then |
---|
483 | if [ -x /sbin/multipath.static ]; then |
---|
484 | modprobe dm-multipath >/dev/null 2>&1 |
---|
485 | /sbin/multipath.static -v 0 |
---|
486 | if [ -x /sbin/kpartx ]; then |
---|
487 | /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a" |
---|
488 | fi |
---|
489 | fi |
---|
490 | |
---|
491 | if [ -x /sbin/dmraid ]; then |
---|
492 | modprobe dm-mirror > /dev/null 2>&1 |
---|
493 | /sbin/dmraid -i -a y |
---|
494 | fi |
---|
495 | |
---|
496 | if [ -x /sbin/lvm ]; then |
---|
497 | if /sbin/lvm vgscan > /dev/null 2>&1 ; then |
---|
498 | action $"Setting up Logical Volume Management:" /sbin/lvm vgscan --mknodes --ignorelockingfailure && /sbin/lvm vgchange -a y --ignorelockingfailure |
---|
499 | fi |
---|
500 | fi |
---|
501 | fi |
---|
502 | fi |
---|
503 | |
---|
504 | if [ -f /etc/raidtab ]; then |
---|
505 | # Add raid devices |
---|
506 | [ -f /proc/mdstat ] || modprobe md >/dev/null 2>&1 |
---|
507 | |
---|
508 | if [ -f /proc/mdstat ]; then |
---|
509 | echo -n $"Starting up RAID devices: " |
---|
510 | |
---|
511 | rc=0 |
---|
512 | |
---|
513 | for i in `awk '{if ($1=="raiddev") print $2}' /etc/raidtab` |
---|
514 | do |
---|
515 | RAIDDEV=`basename $i` |
---|
516 | RAIDSTAT=`LC_ALL=C grep "^$RAIDDEV : active" /proc/mdstat` |
---|
517 | if [ -z "$RAIDSTAT" ]; then |
---|
518 | # First scan the /etc/fstab for the "noauto"-flag |
---|
519 | # for this device. If found, skip the initialization |
---|
520 | # for it to avoid dropping to a shell on errors. |
---|
521 | # If not, try raidstart...if that fails then |
---|
522 | # fall back to raidadd, raidrun. If that |
---|
523 | # also fails, then we drop to a shell |
---|
524 | RESULT=1 |
---|
525 | INFSTAB=`LC_ALL=C grep -c "^$i" /etc/fstab` |
---|
526 | if [ $INFSTAB -eq 0 ] ; then |
---|
527 | RESULT=0 |
---|
528 | RAIDDEV="$RAIDDEV(skipped)" |
---|
529 | fi |
---|
530 | NOAUTO=`LC_ALL=C grep "^$i" /etc/fstab | LC_ALL=C fgrep -c "noauto"` |
---|
531 | if [ $NOAUTO -gt 0 ]; then |
---|
532 | RESULT=0 |
---|
533 | RAIDDEV="$RAIDDEV(skipped)" |
---|
534 | fi |
---|
535 | if [ $RESULT -gt 0 -a -x /sbin/mdadm ]; then |
---|
536 | /sbin/mdadm -Ac partitions $i -m dev |
---|
537 | RESULT=$? |
---|
538 | fi |
---|
539 | if [ $RESULT -gt 0 -a -x /sbin/raidstart ]; then |
---|
540 | /sbin/raidstart $i |
---|
541 | RESULT=$? |
---|
542 | fi |
---|
543 | if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then |
---|
544 | /sbin/raid0run $i |
---|
545 | RESULT=$? |
---|
546 | fi |
---|
547 | if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then |
---|
548 | /sbin/raidadd $i |
---|
549 | /sbin/raidrun $i |
---|
550 | RESULT=$? |
---|
551 | fi |
---|
552 | if [ $RESULT -gt 0 ]; then |
---|
553 | rc=1 |
---|
554 | fi |
---|
555 | echo -n "$RAIDDEV " |
---|
556 | else |
---|
557 | echo -n "$RAIDDEV " |
---|
558 | fi |
---|
559 | done |
---|
560 | echo |
---|
561 | |
---|
562 | # A non-zero return means there were problems. |
---|
563 | if [ $rc -gt 0 ]; then |
---|
564 | echo |
---|
565 | echo |
---|
566 | echo $"*** An error occurred during the RAID startup" |
---|
567 | echo $"*** Dropping you to a shell; the system will reboot" |
---|
568 | echo $"*** when you leave the shell." |
---|
569 | |
---|
570 | str=$"(RAID Repair)" |
---|
571 | PS1="$str \# # "; export PS1 |
---|
572 | sulogin |
---|
573 | |
---|
574 | echo $"Unmounting file systems" |
---|
575 | umount -a |
---|
576 | mount -n -o remount,ro / |
---|
577 | echo $"Automatic reboot in progress." |
---|
578 | reboot -f |
---|
579 | fi |
---|
580 | # LVM2 initialization, take 2 |
---|
581 | if [ -c /dev/mapper/control ]; then |
---|
582 | if [ -x /sbin/multipath.static ]; then |
---|
583 | modprobe dm-multipath >/dev/null 2>&1 |
---|
584 | /sbin/multipath.static -v 0 |
---|
585 | if [ -x /sbin/kpartx ]; then |
---|
586 | /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a" |
---|
587 | fi |
---|
588 | fi |
---|
589 | |
---|
590 | if [ -x /sbin/dmraid ]; then |
---|
591 | modprobe dm-mirror > /dev/null 2>&1 |
---|
592 | /sbin/dmraid -i -a y |
---|
593 | fi |
---|
594 | |
---|
595 | if [ -x /sbin/lvm ]; then |
---|
596 | if /sbin/lvm vgscan > /dev/null 2>&1 ; then |
---|
597 | action $"Setting up Logical Volume Management:" /sbin/lvm vgscan --mknodes --ignorelockingfailure && /sbin/lvm vgchange -a y --ignorelockingfailure |
---|
598 | fi |
---|
599 | fi |
---|
600 | fi |
---|
601 | fi |
---|
602 | fi |
---|
603 | |
---|
604 | update_boot_stage RCfsck |
---|
605 | |
---|
606 | _RUN_QUOTACHECK=0 |
---|
607 | # Check filesystems |
---|
608 | if [ -z "$fastboot" ]; then |
---|
609 | STRING=$"Checking filesystems" |
---|
610 | echo $STRING |
---|
611 | initlog -c "fsck -T -R -A -a $fsckoptions" |
---|
612 | rc=$? |
---|
613 | if [ "$rc" = "0" ]; then |
---|
614 | success "$STRING" |
---|
615 | echo |
---|
616 | elif [ "$rc" = "1" ]; then |
---|
617 | passed "$STRING" |
---|
618 | echo |
---|
619 | fi |
---|
620 | |
---|
621 | # A return of 2 or higher means there were serious problems. |
---|
622 | if [ $rc -gt 1 ]; then |
---|
623 | failure "$STRING" |
---|
624 | echo |
---|
625 | echo |
---|
626 | echo $"*** An error occurred during the file system check." |
---|
627 | echo $"*** Dropping you to a shell; the system will reboot" |
---|
628 | echo $"*** when you leave the shell." |
---|
629 | |
---|
630 | PS1=$"(Repair filesystem) \# # "; export PS1 |
---|
631 | sulogin |
---|
632 | |
---|
633 | echo $"Unmounting file systems" |
---|
634 | umount -a |
---|
635 | mount -n -o remount,ro / |
---|
636 | echo $"Automatic reboot in progress." |
---|
637 | reboot -f |
---|
638 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then |
---|
639 | _RUN_QUOTACHECK=1 |
---|
640 | fi |
---|
641 | fi |
---|
642 | |
---|
643 | update_boot_stage RClocalfs |
---|
644 | |
---|
645 | # Mount all other filesystems (except for NFS and /proc, which is already |
---|
646 | # mounted). Contrary to standard usage, |
---|
647 | # filesystems are NOT unmounted in single user mode. |
---|
648 | action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev |
---|
649 | |
---|
650 | # check remaining quotas other than root |
---|
651 | if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then |
---|
652 | if [ -x /sbin/convertquota ]; then |
---|
653 | # try to convert old quotas |
---|
654 | for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do |
---|
655 | if [ -f "$mountpt/quota.user" ]; then |
---|
656 | action $"Converting old user quota files: " \ |
---|
657 | /sbin/convertquota -u $mountpt && \ |
---|
658 | rm -f $mountpt/quota.user |
---|
659 | fi |
---|
660 | if [ -f "$mountpt/quota.group" ]; then |
---|
661 | action $"Converting old group quota files: " \ |
---|
662 | /sbin/convertquota -g $mountpt && \ |
---|
663 | rm -f $mountpt/quota.group |
---|
664 | fi |
---|
665 | done |
---|
666 | fi |
---|
667 | action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug |
---|
668 | fi |
---|
669 | |
---|
670 | if [ -x /sbin/quotaon ]; then |
---|
671 | action $"Enabling local filesystem quotas: " /sbin/quotaon -aug |
---|
672 | fi |
---|
673 | |
---|
674 | # Configure machine if necessary. |
---|
675 | if [ -f /.unconfigured ]; then |
---|
676 | if [ -x /usr/bin/system-config-keyboard ]; then |
---|
677 | /usr/bin/system-config-keyboard |
---|
678 | fi |
---|
679 | if [ -x /usr/bin/passwd ]; then |
---|
680 | /usr/bin/passwd root |
---|
681 | fi |
---|
682 | if [ -x /usr/sbin/system-config-network-tui ]; then |
---|
683 | /usr/sbin/system-config-network-tui |
---|
684 | fi |
---|
685 | if [ -x /usr/sbin/timeconfig ]; then |
---|
686 | /usr/sbin/timeconfig |
---|
687 | fi |
---|
688 | if [ -x /usr/sbin/authconfig-tui ]; then |
---|
689 | /usr/sbin/authconfig-tui --nostart |
---|
690 | fi |
---|
691 | if [ -x /usr/sbin/ntsysv ]; then |
---|
692 | /usr/sbin/ntsysv --level 35 |
---|
693 | fi |
---|
694 | |
---|
695 | # Reread in network configuration data. |
---|
696 | if [ -f /etc/sysconfig/network ]; then |
---|
697 | . /etc/sysconfig/network |
---|
698 | |
---|
699 | # Reset the hostname. |
---|
700 | action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
---|
701 | fi |
---|
702 | |
---|
703 | rm -f /.unconfigured |
---|
704 | fi |
---|
705 | |
---|
706 | # Clean out /etc. |
---|
707 | rm -f /fastboot /fsckoptions /forcefsck /.autofsck /halt /poweroff |
---|
708 | |
---|
709 | # Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... |
---|
710 | _NEED_XFILES= |
---|
711 | [ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1 |
---|
712 | |
---|
713 | # Clean up /var |
---|
714 | rm -rf /var/lock/cvs/* /var/run/screen/* |
---|
715 | find /var/lock /var/run -type f -exec rm -f {} \; |
---|
716 | |
---|
717 | rm -f /var/lib/rpm/__db* &> /dev/null |
---|
718 | rm -f /var/gdm/.gdmfifo &> /dev/null |
---|
719 | |
---|
720 | # Reset pam_console permissions |
---|
721 | [ -x /sbin/pam_console_apply ] && /sbin/pam_console_apply -r |
---|
722 | |
---|
723 | { |
---|
724 | # Clean up utmp/wtmp |
---|
725 | >/var/run/utmp |
---|
726 | touch /var/log/wtmp |
---|
727 | chgrp utmp /var/run/utmp /var/log/wtmp |
---|
728 | chmod 0664 /var/run/utmp /var/log/wtmp |
---|
729 | if [ -n "$_NEED_XFILES" ]; then |
---|
730 | >/var/run/utmpx |
---|
731 | touch /var/log/wtmpx |
---|
732 | chgrp utmp /var/run/utmpx /var/log/wtmpx |
---|
733 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
---|
734 | fi |
---|
735 | |
---|
736 | # Clean up various /tmp bits |
---|
737 | rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* \ |
---|
738 | /tmp/.esd/* |
---|
739 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ |
---|
740 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
---|
741 | /tmp/scrollkeeper-* /tmp/ssh-* |
---|
742 | # Make ICE directory |
---|
743 | mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1 |
---|
744 | chown root:root /tmp/.ICE-unix |
---|
745 | |
---|
746 | # Now turn on swap in case we swap to files. |
---|
747 | swapon -a |
---|
748 | action $"Enabling swap space: " /bin/true |
---|
749 | |
---|
750 | # Initialize the serial ports. |
---|
751 | if [ -f /etc/rc.serial ]; then |
---|
752 | . /etc/rc.serial |
---|
753 | fi |
---|
754 | |
---|
755 | update_boot_stage RCusbstorage |
---|
756 | |
---|
757 | # Load usb storage here, to match most other things |
---|
758 | if [ -n "$needusbstorage" ]; then |
---|
759 | modprobe usb-storage >/dev/null 2>&1 |
---|
760 | fi |
---|
761 | |
---|
762 | # Adjust symlinks as necessary in /boot to keep system services from |
---|
763 | # spewing messages about mismatched System maps and so on. |
---|
764 | if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ]; then |
---|
765 | ln -s -f System.map-`uname -r` /boot/System.map |
---|
766 | fi |
---|
767 | if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then |
---|
768 | ln -s -f System.map-`uname -r` /boot/System.map |
---|
769 | fi |
---|
770 | |
---|
771 | # Now that we have all of our basic modules loaded and the kernel going, |
---|
772 | # let's dump the syslog ring somewhere so we can find it later |
---|
773 | dmesg -s 131072 > /var/log/dmesg |
---|
774 | # Also keep kernel symbols around in case we need them for debugging |
---|
775 | i=5 |
---|
776 | while [ $i -ge 0 ] ; do |
---|
777 | if [ -f /var/log/ksyms.$i ] ; then |
---|
778 | mv /var/log/ksyms.$i /var/log/ksyms.$(($i+1)) |
---|
779 | fi |
---|
780 | i=$(($i-1)) |
---|
781 | done |
---|
782 | if [ "$KERNELVERSION" = "2.6" ]; then |
---|
783 | _ksyms=/proc/kallsyms |
---|
784 | else |
---|
785 | _ksyms=/proc/ksyms |
---|
786 | fi |
---|
787 | (/bin/date; |
---|
788 | /bin/uname -a; |
---|
789 | /bin/cat /proc/cpuinfo; |
---|
790 | /bin/cat /proc/modules; |
---|
791 | /bin/cat ${_ksyms}) >/var/log/ksyms.0 |
---|
792 | # create the crash indicator flag to warn on crashes, offer fsck with timeout |
---|
793 | touch /.autofsck |
---|
794 | kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1 |
---|
795 | } & |
---|
796 | if [ "$PROMPT" != "no" ]; then |
---|
797 | /sbin/getkey i && touch /var/run/confirm |
---|
798 | fi |
---|
799 | wait |
---|
800 | |
---|
801 | #rc_splash "master" |
---|