]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/rc.sysinit
Merge color customization support created by Łukasz Pawelczyk <havner/at/pld-linux...
[projects/rc-scripts.git] / rc.d / rc.sysinit
1 #!/bin/sh
2 #
3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id$
5 #
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes:      Arkadiusz Mi¶kiewicz <misiek@pld-linux.org>
8 #
9
10 # Set the path
11 PATH=/bin:/sbin:/usr/bin:/usr/sbin
12 export PATH
13
14 # reasonable start values for bootsplash progress.
15 export progress=0
16 export sscripts=45
17 export kscripts=45
18
19 # Read functions
20 . /etc/rc.d/init.d/functions
21
22 # we need /proc mounted before everything
23 mount -n -o gid=17 -t proc /proc /proc
24
25 # sysfs is also needed before any other things (under kernel > 2.5)
26 if grep -q sysfs /proc/filesystems ; then
27     mount -n -o gid=17 -t sysfs sysfs /sys
28 fi
29
30 # selinux
31 if grep -q selinuxfs /proc/filesystems && ! grep -q selinuxfs /proc/mounts; then
32     mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
33 fi
34
35 # Choose Hardware profile
36 rm -f /var/run/hwprofile 2> /dev/null
37 if [ -f /etc/sysconfig/hwprof ]; then
38     . /etc/sysconfig/hwprof
39     if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
40        mount -n / -o rw,remount
41        /sbin/hwprofile -qf
42        mount -n / -o ro,remount
43     fi
44 fi
45
46 # NLS
47 if [ -r /etc/sysconfig/i18n ]; then
48         . /etc/sysconfig/i18n
49         [ -n "$LANG" ] && export LANG || unset LANG
50         [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
51         [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
52         [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
53         [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
54         [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
55         [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
56         [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
57         [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
58         [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
59 fi
60
61 # Read network config data
62 if [ -r /etc/sysconfig/network ]; then
63         . /etc/sysconfig/network
64 else
65         NETWORKING=no
66         HOSTNAME=localhost
67 fi
68
69 # Read system config data
70 if [ -r /etc/sysconfig/system ]; then
71         . /etc/sysconfig/system
72 else
73         RUN_SULOGIN_ON_ERR=yes
74         RUN_USERPNP=yes
75         RUN_KERNELPNP=yes
76         PANIC_REBOOT_TIME=0
77         DELAY_LOGIN=yes
78         CLEAN_TMP=no
79         CONSOLE_LOGLEVEL=1
80         SET_SLINKS=yes
81         RUN_LDCONFIG=yes
82 fi
83
84 # Disable splash when requested
85 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
86                                     
87 # Print welcome message
88 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
89 if is_yes "$PROMPT"; then
90         nls -n "\t\t  Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
91         echo
92         sleep 1
93 fi
94
95 # Set console loglevel
96 if [ -n "$CONSOLE_LOGLEVEL" ]; then
97         /bin/dmesg -n $CONSOLE_LOGLEVEL
98 fi
99
100 # /dev must be also mounted before everything but only if we want use them ;-)
101 if is_yes "$MOUNT_DEVFS"; then
102         run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
103 fi
104
105 # set up devfsd
106 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
107         run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
108 fi
109
110 # Configure Linux kernel (initial configuration, some required modules still
111 # may be missing).
112 /sbin/sysctl -p /etc/sysctl.conf > /dev/null 2>&1
113
114 # Set the system clock.
115 ARC=0
116 SRM=0
117 UTC=0
118
119 if [ -f /etc/sysconfig/clock ]; then
120         . /etc/sysconfig/clock
121
122         # convert old style clock config to new values
123         if [ "${CLOCKMODE}" = "GMT" ]; then
124                 UTC=true
125         elif [ "${CLOCKMODE}" = "ARC" ]; then
126                 ARC=true
127         fi
128 fi
129
130 if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
131         ARC=true
132 fi
133
134 CLOCKDEF=""
135 CLOCKFLAGS="--hctosys"
136
137 if is_yes "$UTC" ; then
138         CLOCKFLAGS="$CLOCKFLAGS --utc"
139         CLOCKDEF="$CLOCKDEF (utc)"
140 else
141         CLOCKFLAGS="$CLOCKFLAGS --localtime"
142         CLOCKDEF="$CLOCKDEF (local)"
143 fi
144
145 if is_yes "$ARC" ; then
146         CLOCKFLAGS="$CLOCKFLAGS -A"
147         CLOCKDEF="$CLOCKDEF (arc)"
148 fi
149
150 if is_yes "$SRM" ; then
151         CLOCKFLAGS="$CLOCKFLAGS -S"
152         CLOCKDEF="$CLOCKDEF (srm)"
153 fi
154
155 # Check if timezone definition is available
156 if [ -e /etc/localtime ] ; then
157         if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
158                 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
159         fi
160 else
161         TIME_SETUP_DELAYED=yes
162 fi
163
164 # Start up swapping
165 run_cmd "Activating swap partitions" swapon -a -e
166
167 # Set the hostname
168 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
169
170 # Set the NIS domain name
171 if [ -n "$NISDOMAIN" ]; then
172         run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
173 else
174         domainname ""
175 fi
176
177 # Initialize USB controllers
178 usb=0
179 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "usb" /proc/devices 2>/dev/null ; then
180         aliases=$(/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }')
181         if [ -n "$aliases" -a "$aliases" != "off" ] ; then
182                 /sbin/modprobe -k usbcore
183                 for alias in $aliases ; do
184                         [ "$alias" = "off" ] && continue
185                         run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe $alias
186                 done
187                 [ $? -eq 0 -a -n "$aliases" ] && usb=1
188         fi
189         if grep -iq "usb" /proc/devices 2>/dev/null ; then
190                 usb=1
191         fi
192 fi
193
194 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
195         run_cmd "Mounting USB filesystem" mount -t usbdevfs usbdevfs /proc/bus/usb
196 fi
197
198 needusbstorage=
199 if [ "$usb" = "1" ]; then
200         needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08")
201         LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2> /dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
202         mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02")
203         kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01")
204         if [ -n "$kbdoutput" ]; then
205                 run_cmd "Initializing USB keyboard" modprobe keybdev
206         fi
207         if [ -n "$mouseoutput" ]; then
208                 run_cmd "Initializing USB mouse" modprobe mousedev
209         fi
210 fi
211
212 # Setup hdparm thing (if exists and is needed)
213 if ! grep -iq nohdparm /proc/cmdline; then
214         [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
215 fi
216
217 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2> /dev/null ; then
218         fastboot=yes
219 else
220         fastboot=
221 fi
222
223 if [ -f /fsckoptions ]; then
224         fsckoptions=$(cat /fsckoptions)
225 else
226         fsckoptions=''
227 fi
228
229 if [ -f /forcefsck ]; then
230         fsckoptions="-f $fsckoptions"
231 fi
232
233 _RUN_QUOTACHECK=0
234 _ROOTFS_TYPE=$(grep " / " /proc/mounts | awk '{ print $3 }')
235
236 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" ]; then 
237         show "Checking root filesystem"; started
238         initlog -c "fsck -C -T -a $fsckoptions /"
239
240         rc=$?
241
242         # A return of 4 or higher means there were serious problems.
243         if [ $rc -gt 3 ]; then
244                 [ -e /proc/splash ] && echo "verbose" > /proc/splash
245                 # don't use '\n' in nls macro !
246                 echo
247                 echo
248                 nls "*** An error occurred during the file system check."
249                 nls "*** Dropping you to a shell; the system will reboot"
250                 nls "*** when you leave the shell."
251                 echo
252
253                 PS1="$(nls '(Repair filesystem)# ')"; export PS1
254                 if is_yes "$RUN_SULOGIN_ON_ERR"; then
255                         sulogin
256                 else
257                         /bin/sh
258                 fi
259
260                 run_cmd "Unmounting file systems" umount -a
261                 mount -n -o remount,ro /
262                 run_cmd "Automatic reboot in progress" reboot
263         # A return of 2 or 3 means that filesystem was repaired but we need
264         # to reboot.
265         elif [ "$rc" = "2" -o "$rc" = "3" ]; then
266                 [ -e /proc/splash ] && echo "verbose" > /proc/splash
267                 echo
268                 nls "*** Filesystem was repaired but system needs to be"
269                 nls "*** rebooted before mounting it."
270                 nls "*** REBOOTING ***"
271                 echo
272
273                 run_cmd "Unmounting file systems" umount -a
274                 mount -n -o remount,ro /
275                 run_cmd "Automatic reboot in progress" reboot
276         elif [ "$rc" = "1" ]; then
277                 _RUN_QUOTACHECK=1
278         fi
279 fi
280
281 # Check for arguments 
282 if grep -iq nopnp /proc/cmdline; then
283         PNP=
284 else
285         PNP=yes
286 fi
287
288 # set up pnp and kernel pnp
289 if [ -n "$PNP" ]; then
290     if is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
291         run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
292     fi
293     if is_yes "$RUN_KERNELPNP"; then
294         /sbin/modprobe -k isa-pnp 2> /dev/null
295         if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
296             show "Setting up ISA PNP devices (kernelspace pnp)"; busy
297             grep -v "^#" /etc/isapnp/isapnp-kernel.conf > /proc/isapnp && (deltext; ok) || (deltext; fail)
298         fi
299     fi
300 fi
301
302 # Remount the root filesystem read-write
303 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
304
305 # Update quotas if fsck was run on /
306 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
307         run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
308 fi
309
310 # Clear mtab
311 :>/etc/mtab
312 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
313
314 # Remove stale backups
315 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
316
317 # Enter root, /proc, /sys, devfs and other into mtab.
318 mount -f /
319 mount -f /proc
320 [ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb
321 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
322
323 if grep -q sysfs /proc/filesystems ; then
324         mount -f -t sysfs sysfs /sys
325 fi
326
327 if grep -q selinuxfs /proc/filesystems ; then
328         mount -f -t selinuxfs selinuxfs /selinux
329 fi
330
331 # Remove /etc/nologin when starting system
332 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
333
334 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
335         show "Enabling Delay Login"; busy
336         echo > /etc/nologin
337         nls "System bootup in progress - please wait" >> /etc/nologin
338         echo >> /etc/nologin
339         chmod 644 /etc/nologin
340         cp -fp /etc/nologin /etc/nologin.boot
341         ok
342 fi
343
344 # The root filesystem is now read-write, so we can now log via
345 # syslog() directly...
346 if [ -n "$IN_INITLOG" ]; then
347         IN_INITLOG=""
348 fi
349
350 if [ ! -f /proc/modules ]; then
351         USEMODULES=
352 elif ! grep -iq nomodules /proc/cmdline; then
353         USEMODULES=y
354 else
355         USEMODULES=
356 fi
357
358 # Adjust symlinks as necessary in /boot to keep system services from
359 # spewing messages about mismatched System maps and so on.
360 if is_yes "$SET_SLINKS"; then
361         if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
362                 ln -s -f System.map-`uname -r` /boot/System.map
363         fi
364         if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
365                 ln -s -f System.map-`uname -r` /boot/System.map
366         fi
367 fi
368
369 # Run depmod if RUN_DEPMOD != "no" and:
370 # a) user requested or RUN_DEPMOD="";
371 # b) modules.dep is missing
372 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
373 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
374         if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
375                 run_cmd "Finding module dependencies" depmod -a
376         elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
377                 run_cmd "Finding module dependencies" depmod -A
378         fi
379 fi
380
381 if [ -f /proc/sys/kernel/modprobe ]; then
382         if [ -n "$USEMODULES" ]; then
383                 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
384                 sysctl -w kernel.hotplug="/sbin/hotplug" >/dev/null 2>&1
385         else
386                 # We used to set this to NULL, but that causes
387                 # 'failed to exec' messages"
388                 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
389                 sysctl -w kernel.hotplug="/bin/true" >/dev/null 2>&1
390         fi
391 fi
392
393 # Load usb storage here, to match most other things
394 if [ -n "$needusbstorage" ]; then
395         modprobe -k usb-storage >/dev/null 2>&1
396 fi
397
398 # Load firewire devices
399 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
400         aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
401         if [ -n "$aliases" -a "$aliases" != "off" ] ; then
402             for alias in $aliases ; do
403                 [ "$alias" = "off" ] && continue
404                 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
405             done
406             LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2> /dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1 
407         fi
408 fi    
409     
410 # Load sound modules if they need persistent DMA buffers
411 if grep -q "options sound dmabuf=1" /etc/modules.conf 2>/dev/null ; then
412         RETURN=0
413         alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" | awk '{ print $3 }')
414         if [ -n "$alias" -a "$alias" != "off" ] ; then
415                 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
416                 RETURN=$?
417         fi
418         alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" | awk '{ print $3 }')
419         if [ -n "$alias" -a "$alias" != "off" ] ; then
420                 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
421                 RETURN=$?
422         fi
423 fi
424
425 # Load modules
426 if [ -x /etc/rc.d/rc.modules ]; then
427         /etc/rc.d/rc.modules
428 fi
429
430 # Find and activate volume groups:
431 # EVMS
432 if [ -x /sbin/evms_activate ]; then
433         # Linux 2.5 core module
434         modprobe -s -k evmscore > /dev/null 2>&1
435         # Linux 2.4 core modules
436         modprobe -s -k evms > /dev/null 2>&1
437         modprobe -s -k evms_passthru > /dev/null 2>&1
438         modprobe -s -k ldev_mgr > /dev/null 2>&1
439         modprobe -s -k dos_part > /dev/null 2>&1
440         is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
441         is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
442         is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
443         is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
444         run_cmd "Discovering EVMS volumes" /sbin/evms_activate
445         if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
446                 # Link nodes for compatibility with LVM
447                 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
448                         ln -s /dev/evms/lvm/* /dev/
449                 fi
450         fi
451 fi
452 # LVM
453 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
454         lvmversion=$(/sbin/vgchange --version 2>/dev/null|head -n 1|awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version:     ",""); gsub(/\..*/,"");print $1}')
455         if [ "$lvmversion" = "1" ] ; then
456                 modprobe -s -k lvm-mod >/dev/null 2>&1
457                 lvmignorelock=""
458         elif [ "$lvmversion" = "2" ] ; then
459                 modprobe -s -k dm-mod >/dev/null 2>&1
460                 lvmignorelock="--ignorelockingfailure"
461         else
462             modprobe -s -k lvm-mod >/dev/null 2>&1
463             # device mapper (2.5+ and patched 2.4)
464             modprobe -s -k dm-mod >/dev/null 2>&1
465             lvmignorelock=""
466         fi
467                         
468     
469         run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
470         run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
471 fi
472
473 # Add raid devices
474 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
475
476         modprobe -s md >/dev/null 2>&1
477         if [ -f /proc/mdstat ]; then
478             goraidtab=1
479             rc=0
480             
481             if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
482                 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf); then
483                     run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan
484                     rc=$?
485                     [ "$rc" -eq 0 ] && goraidtab=0
486                 fi
487             fi
488             
489             if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
490                 
491                 for i in $(grep -v "^#" /etc/raidtab | grep "raiddev" | awk '{print $2}') ; do
492                     RAIDDEV=$(basename $i)
493                     RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
494                     show "Starting up RAID device %s" $RAIDDEV
495                     busy
496                     if [ -z "$RAIDSTAT" ]; then
497                         # Try raidstart first...if that fails then
498                         # fall back to raid0run and if that fails too
499                         # fall back to raidadd, raidrun.
500                         RESULT=1
501                         if [ -x /sbin/raidstart ]; then
502                                 /sbin/raidstart $i
503                                 RESULT=$?
504                         fi
505                         if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
506                                 /sbin/raid0run $i
507                                 RESULT=$?
508                         fi
509                         if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
510                                 /sbin/raidadd $i
511                                 /sbin/raidrun $i
512                                 RESULT=$?
513                         fi
514                         if [ $RESULT -gt 0 ]; then
515                                 rc=1
516                                 fail
517                         else
518                                 ok
519                         fi
520                     else
521                         ok
522                     fi
523                 done
524             fi
525
526             # A non-zero return means there were problems
527             if [ $rc -gt 0 ]; then
528                 [ -e /proc/splash ] && echo "verbose" > /proc/splash
529                 show "Starting up RAID devices"; fail
530                 echo
531                 echo
532                 nls "*** An error occurred during the RAID startup."
533                 nls "*** Dropping you to a shell; the system will reboot"
534                 nls "*** when you leave the shell."
535                 echo
536
537                 PS1="$(nls '(RAID Repair)# ')"; export PS1
538                 if is_yes "$RUN_SULOGIN_ON_ERR"; then
539                         sulogin
540                 else
541                         /bin/sh
542                 fi
543
544                 run_cmd "Unmounting file systems" umount -a
545                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
546                 run_cmd "Automatic reboot in progress" reboot
547             fi
548             if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
549                 run_cmd "Scanning for LVM volume groups" /sbin/vgscan && \
550                         run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
551             fi
552             show "Starting up RAID devices"; ok
553         fi
554 fi
555
556 _RUN_QUOTACHECK=0
557 # Check filesystems
558 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline; then
559         rc_splash "fsck start"
560         show "Checking filesystems"; started
561         initlog -c "fsck -C -T -R -A -a $fsckoptions"
562
563         rc=$?
564
565         # A return of 2 or higher means there were serious problems
566         if [ $rc -gt 1 ]; then
567                 [ -e /proc/splash ] && echo "verbose" > /proc/splash
568                 echo
569                 echo
570                 nls "*** An error occurred during the file system check."
571                 nls "*** Dropping you to a shell; the system will reboot"
572                 nls "*** when you leave the shell."
573                 echo
574
575                 PS1="$(nls '(Repair filesystem)# ')"; export PS1
576                 if is_yes "$RUN_SULOGIN_ON_ERR"; then
577                         sulogin
578                 else
579                         /bin/sh
580                 fi
581
582                 run_cmd "Unmounting file systems" umount -a
583                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
584                 run_cmd "Automatic reboot in progress" reboot
585         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
586                 _RUN_QUOTACHECK=1
587         fi
588         rc_splash "fsck stop"
589 fi
590
591 # Mount all other filesystems (except for NFS and /proc, which is already
592 # mounted). Contrary to standard usage,
593 # filesystems are NOT unmounted in single user mode.
594
595 run_cmd "Mounting local filesystems" mount -a -t nonfs,smbfs,ncpfs,proc,cifs -O no_netdev
596
597 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
598 # before mount - that's where the password is entered.
599 # mount is buggy - when remounting loopback filesystem, loop=XXX
600 # option is removed from /etc/mtab
601 if grep "^[^#].*encryption=" /etc/fstab | grep -v -q "noauto"; then
602         show "Checking encrypted filesystems"; started
603         LOOPLIST="$(awk '
604         FILENAME=="/proc/mounts" {
605                 TAB[$2]=$1;
606         }
607         FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
608                 if ($2 in TAB){print TAB[$2];}
609         }
610         FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
611                 if ($2 in TAB){print TAB[$2];}
612                 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
613                 cmd="mount " $2 " -o remount," $4;
614                 system(cmd);
615         }
616         ' /proc/mounts /etc/fstab)"
617         initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
618         rc=$?
619
620         # A return of 2 or higher means there were serious problems.
621         if [ $rc -gt 1 ]; then
622                 [ -e /proc/splash ] && echo "verbose" > /proc/splash
623                 echo
624                 echo
625                 nls "*** An error occurred during the file system check."
626                 nls "*** Dropping you to a shell; the system will reboot"
627                 nls "*** when you leave the shell."
628                 echo
629
630                 PS1="`nls '(Repair filesystem)# '`"; export PS1
631                 if is_yes "$RUN_SULOGIN_ON_ERR"; then
632                         sulogin
633                 else
634                         /bin/sh
635                 fi
636
637                 run_cmd "Unmounting file systems" umount -a
638                 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
639                 run_cmd "Automatic reboot in progress" reboot
640         elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
641                 _RUN_QUOTACHECK=1
642         fi
643         
644         show "Remounting encrypted filesystems back in rw mode"; busy
645         awk '
646         FILENAME=="/proc/mounts" {
647                 TAB[$2]=$1;
648         }
649         FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
650                 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
651                 cmd="mount " $2 " -o remount," $4;
652                 system(cmd);
653         }
654         ' /proc/mounts /etc/fstab
655         ok
656 fi
657
658 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
659         run_cmd "Checking filesystem quotas"  /sbin/quotacheck -vnugRa
660 fi
661
662 # Turn on quota
663 if [ -x /sbin/quotaon ]; then
664         run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
665 fi
666
667 # Turn on process accounting
668 if [ -x /etc/rc.d/rc.acct ]; then
669         /etc/rc.d/rc.acct start
670 fi
671
672 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
673 if is_yes "$TIME_SETUP_DELAYED"; then
674         if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
675                 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
676         fi
677 fi
678
679 # Initialize the serial ports
680 if [ -f /etc/rc.d/rc.serial ]; then
681         . /etc/rc.d/rc.serial
682 fi
683
684 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
685         show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
686         if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
687 fi
688
689 # ... and here finish configuring parameters
690 run_cmd "Configuring kernel parameters" /sbin/sysctl -p /etc/sysctl.conf
691
692 # Clean up /etc.
693 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
694
695 # Clean up /var
696 # I'd use find, but /usr may not be mounted.
697 for afile in /var/lock/* /var/run/*; do
698         bafile=$(basename $afile)
699         if [ -d "$afile" ]; then
700                 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -rf $afile/*
701         else
702                 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
703         fi
704 done
705 # Delete stale files
706 rm -f /var/lib/rpm/__db*
707 rm -f /var/spool/postoffice/.pid.*
708
709 {
710 # Clean up utmp/wtmp
711 if ! is_no "$NEED_XFILES" ; then
712         :>/var/run/utmpx
713         touch /var/log/wtmpx
714         chown root.utmp /var/run/utmpx /var/log/wtmpx
715         chmod 0664 /var/run/utmpx /var/log/wtmpx
716 else
717         :>/var/run/utmp
718         touch /var/log/wtmp
719         chown root.utmp /var/run/utmp /var/log/wtmp
720         chmod 0664 /var/run/utmp /var/log/wtmp
721 fi
722
723 # Clean /tmp
724 if is_yes "$CLEAN_TMP"; then
725         rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
726 fi
727
728 # Right, now turn on swap in case we swap to files
729 swapon -a >/dev/null 2>&1
730 run_cmd "Enabling swap space" /bin/true
731
732 # If a SCSI tape has been detected, load the st module unconditionally
733 # since many SCSI tapes don't deal well with st being loaded and unloaded
734 if [ -f /proc/scsi/scsi ] && grep -q 'Type:   Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
735         if grep -qv ' 9 st' /proc/devices; then
736                 if [ -n "$USEMODULES" ] ; then
737                         # Try to load the module. If it fails, ignore it...
738                         insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
739                 fi
740         fi
741 fi
742
743 # There could be a new kernel version. Remove old psdevtab database
744 rm -f /etc/psdevtab
745
746 # Now that we have all of our basic modules loaded and the kernel going,
747 # let's dump the syslog ring somewhere so we can find it later
748 dmesg -s 131072 > /var/log/dmesg
749 i=5
750 while [ $i -ge 0 ]; do
751         if [ -f /var/log/dmesg.$i ]; then
752             chmod 0600 /var/log/dmesg.$i
753             mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
754         fi
755         i=$(($i-1))
756 done
757 cp -f /var/log/dmesg /var/log/dmesg.0
758 chmod 0600 /var/log/dmesg /var/log/dmesg.0
759
760 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
761 } &
762 if is_yes "$PROMPT"; then
763         /sbin/getkey i && touch /var/run/confirm
764 fi
765 wait
766 echo
767
768 # This must be last line !
769 # vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.080879 seconds and 3 git commands to generate.