source: projects/initscripts/trunk/rc.d/rc.sysinit @ 3551

Revision 3551, 21.7 KB checked in by daisuke, 15 years ago (diff)

fix more

Line 
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
9PATH=/bin:/sbin:/usr/bin:/usr/sbin
10export PATH
11
12HOSTNAME=`/bin/hostname`
13HOSTTYPE=`uname -m`
14KERNELRELEASE=`uname -r`
15KERNELVERSION=`echo $KERNELRELEASE | cut -f 1-2 -d.`
16
17# VLEE: make host dependent /etc
18if [ -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
25elif [ -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
32fi
33
34# Read in config data.
35if [ -f /etc/sysconfig/network ]; then
36    . /etc/sysconfig/network
37else
38    NETWORKING=no
39fi
40
41if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
42    HOSTNAME=localhost
43fi
44
45# Mount /proc, /sys
46if [ ! -e /proc/mounts ]; then
47        mount -n -t proc /proc /proc
48        mount -n -t sysfs /sys /sys >/dev/null 2>&1
49fi
50if [ ! -d /proc/bus/usb ]; then
51        modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb
52else
53        mount -n -t usbfs /proc/bus/usb /proc/bus/usb
54fi
55
56# readahead
57if [ -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
62elif [ -x /sbin/readahead_early ]; then
63    /sbin/readahead_early &
64fi
65
66if [ -x /etc/rc.early.local ]; then
67    . /etc/rc.early.local
68fi
69
70# Source functions
71. /etc/init.d/functions
72
73PLYMOUTH=
74[ -x /usr/bin/plymouth ] && PLYMOUTH=yes
75
76# Print a banner. ;)
77echo -en $"\t\t\tWelcome to "
78[ "$BOOTUP" != "serial" ] && echo -en $"\\033[1;36m"
79echo -en $"Vine"
80[ "$BOOTUP" != "serial" ] && echo -en $"\\033[0;39m"
81echo $" Linux"
82if [ "$PROMPT" != "no" ]; then
83 echo -en $"\t\tPress 'I' to enter interactive startup."
84 echo
85fi
86
87# Fix console loglevel
88/bin/dmesg -n $LOGLEVEL
89
90# read /proc/cmdline once
91cmdline=$(cat /proc/cmdline)
92
93# Initialize hardware
94if [ -f /proc/sys/kernel/modprobe ]; then
95   if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then
96      sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
97   else
98      sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
99   fi
100fi
101         
102# kill nash and start udev
103nashpid=$(pidof nash 2>/dev/null)
104[ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1
105unset nashpid
106/sbin/start_udev
107
108# Load user-defined modules
109for file in /etc/sysconfig/modules/*.modules ; do
110   [ -x $file ] && $file
111done
112
113# Load modules (for backward compatibility with VARs)
114if [ -f /etc/rc.modules ]; then
115        /etc/rc.modules
116fi
117
118# VLEE: make and mount /dev
119if [ -x /etc/rc.MAKEDEV ]; then
120   action $"Making and Mounting /dev filesystem: " /etc/rc.MAKEDEV
121elif [ -x /DLKit/etc/rc.MAKEDEV ]; then
122   action $"Making and Mounting /dev filesystem: " /DLKit/etc/rc.MAKEDEV
123fi
124
125# Unmount the initrd, if necessary
126if grep -q /initrd /proc/mounts && ! grep -q /initrd/loopfs /proc/mounts ; then
127   action $"Unmounting initrd: " umount /initrd
128   /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
129fi
130
131# load SCSI modules
132for module in `/sbin/modprobe -c | LC_ALL=C awk '/^alias[[:space:]]+scsi_hostadapter[0-9]*[[:space:]]/ { print $3 }'`
133do
134   if ( modprobe --dry-run $module 2> /dev/null ) ; then
135       action $"Loading SCSI module ($module): " /sbin/modprobe $module
136   fi
137done
138
139# Configure kernel parameters
140update_boot_stage RCkernelparam
141action $"Configuring kernel parameters: " sysctl -e -p /etc/sysctl.conf
142
143# Set the system clock.
144ARC=0
145SRM=0
146UTC=0
147
148if [ -f /etc/sysconfig/clock ]; then
149   . /etc/sysconfig/clock
150
151   # convert old style clock config to new values
152   if [ "${CLOCKMODE}" = "GMT" ]; then
153      UTC=true
154   elif [ "${CLOCKMODE}" = "ARC" ]; then
155      ARC=true
156   fi
157fi
158
159CLOCKDEF=""
160CLOCKFLAGS="$CLOCKFLAGS --hctosys"
161
162case "$UTC" in
163   yes|true)
164    CLOCKFLAGS="$CLOCKFLAGS --utc";
165    CLOCKDEF="$CLOCKDEF (utc)";
166   ;;
167   no|false)
168    CLOCKFLAGS="$CLOCKFLAGS --localtime";
169    CLOCKDEF="$CLOCKDEF (localtime)";
170   ;;
171esac
172
173case "$ARC" in
174     yes|true)
175        CLOCKFLAGS="$CLOCKFLAGS --arc";
176        CLOCKDEF="$CLOCKDEF (arc)";
177     ;;
178esac
179case "$SRM" in
180     yes|true)
181        CLOCKFLAGS="$CLOCKFLAGS --srm";
182        CLOCKDEF="$CLOCKDEF (srm)";
183     ;;
184esac
185
186/sbin/hwclock $CLOCKFLAGS
187
188action $"Setting clock $CLOCKDEF: `date`" date
189
190if [ "`/sbin/consoletype`" = "vt" ]; then
191  # Load keymap
192  if [ -x /bin/loadkeys ]; then
193    KEYTABLE=
194    KEYMAP=
195    if [ -f /etc/sysconfig/console/default.kmap ]; then
196      KEYMAP=/etc/sysconfig/console/default.kmap
197    else
198      if [ -f /etc/sysconfig/keyboard ]; then
199        . /etc/sysconfig/keyboard
200      fi
201      if [ -n "$KEYTABLE" -a -d "/lib/kbd/keymaps" ]; then
202        KEYMAP=$KEYTABLE
203      fi
204    fi
205    if [ -n "$KEYMAP" ]; then
206      # Since this takes in/output from stdin/out, we can't use initlog
207      if [ -n "$KEYTABLE" ]; then
208        echo -n $"Loading default keymap ($KEYTABLE): "
209      else
210        echo -n $"Loading default keymap: "
211      fi
212      loadkeys $KEYMAP < /dev/tty0 > /dev/tty0 2>/dev/null && \
213        success $"Loading default keymap" || failure $"Loading default keymap"
214      echo
215    fi   
216  fi
217fi
218
219# Start up swapping.
220action $"Activating swap partitions: " swapon -a -e
221
222# Set the hostname.
223update_boot_stage RChostname
224action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
225
226# Sync waiting for storage.
227{ rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1
228
229#echo "raidautorun /dev/md0" | nash --quiet
230[ -f /etc/mdadm.conf -a -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run
231
232# LVM2 initialization
233if [ -x /sbin/lvm -o -x /sbin/multipath.static -o -x /sbin/dmraid.static ]; then
234    if ! LC_ALL=C fgrep -q "device-mapper" /proc/devices 2>/dev/null ; then
235        modprobe dm-mod >/dev/null 2>&1
236    fi
237    #echo "mkdmnod" | /sbin/nash --quiet >/dev/null 2>&1
238fi
239
240if [ -c /dev/mapper/control ]; then
241    if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf -a -x /sbin/multipath.static ]; then
242        modprobe dm-multipath >/dev/null 2>&1
243        /sbin/multipath.static -v 0
244        if [ -x /sbin/kpartx ]; then
245                /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a"
246        fi
247    fi
248
249    if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid.static ]; then
250        modprobe dm-mirror > /dev/null 2>&1
251        /sbin/dmraid.static -i -ay
252    fi
253   
254    if [ -x /sbin/lvm ]; then
255        if /sbin/lvm vgscan --mknodes --ignorelockingfailure > /dev/null 2>&1 ; then
256            action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --ignorelockingfailure
257        fi
258    fi
259fi
260
261update_boot_stage RCfsck
262
263if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then
264        fastboot=yes
265    else
266        fastboot=
267fi
268
269if [ -f /fsckoptions ]; then
270        fsckoptions=`cat /fsckoptions`
271    else
272        fsckoptions=
273fi
274
275READONLY=
276if [ -f /etc/sysconfig/readonly-root ]; then
277        . /etc/sysconfig/readonly-root
278fi
279if strstr "$cmdline" readonlyroot ; then
280        READONLY=yes
281fi
282if strstr "$cmdline" noreadonlyroot ; then
283        READONLY=no
284fi
285                                       
286
287if [ -f /forcefsck ]; then
288        fsckoptions="-f $fsckoptions"
289elif [ -f /.autofsck ]; then
290        echo $"Your system appears to have shut down uncleanly"
291        AUTOFSCK_TIMEOUT=5
292        AUTOFSCK_DEF_CHECK=no
293        [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck
294        if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then
295                AUTOFSCK_OPT=-f
296        else
297                AUTOFSCK_OPT=
298        fi
299
300        if [ "$PROMPT" != "no" ]; then
301                if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then
302                        if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press N within %d seconds to not force file system integrity check..." n ; then
303                                AUTOFSCK_OPT=
304                        fi
305                else
306                        if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press Y within %d seconds to force file system integrity check..." y ; then
307                                AUTOFSCK_OPT=-f
308                        fi
309                fi
310                echo
311        else
312                # PROMPT not allowed
313                if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then
314                        echo $"Forcing file system integrity check due to default setting"
315                else
316                        echo $"Not forcing file system integrity check due to default setting"
317                fi
318        fi
319        fsckoptions="$AUTOFSCK_OPT $fsckoptions"
320fi
321
322if [ "$BOOTUP" != "serial" ]; then
323        fsckoptions="-C $fsckoptions"
324else
325        fsckoptions="-V $fsckoptions"
326fi
327 
328_RUN_QUOTACHECK=0
329ROOTFSTYPE=`grep " / " /proc/mounts | awk '{ print $3 }'`
330if [ -z "$fastboot" -a "$READONLY" != "yes" -a "$ROOTFSTYPE" != "nfs" -a "$ROOTFSTYPE" != "reiserfs" -a "$ROOTFSTYPE" != "unionfs" -a "$ROOTFSTYPE" != "squashfs" ]; then
331
332        STRING=$"Checking root filesystem"
333        echo $STRING
334        fsck -T -a $fsckoptions /
335        rc=$?
336       
337        if [ "$rc" = "0" ]; then
338                success "$STRING"
339                echo
340        elif [ "$rc" = "1" ]; then
341                passed $"$STRING"
342                echo
343        fi
344       
345        # A return of 2 or higher means there were serious problems.
346        if [ $rc -gt 1 ]; then
347                [ -n "$PLYMOUTH" ] && plymouth --hide-splash
348
349                failure "$STRING"
350                echo
351                echo
352                echo $"*** An error occurred during the file system check."
353                echo $"*** Dropping you to a shell; the system will reboot"
354                echo $"*** when you leave the shell."
355
356                PS1=$"(Repair filesystem) \# # "; export PS1
357                sulogin
358
359                echo $"Unmounting file systems"
360                umount -a
361                mount -n -o remount,ro /
362                echo $"Automatic reboot in progress."
363                reboot -f
364        elif [ "$rc" = "1" ]; then
365                _RUN_QUOTACHECK=1
366        fi
367fi
368
369update_boot_stage RCquotacheck
370
371# Possibly update quotas if fsck was run on /.
372grep -E '[[:space:]]+/[[:space:]]+' /etc/fstab | \
373    awk '{ print $4 }' | \
374    grep -q quota
375_ROOT_HAS_QUOTA=$?
376if [ X"$_RUN_QUOTACHECK" = X1 -a \
377    "$_ROOT_HAS_QUOTA" -a \
378    -x /sbin/quotacheck ]; then
379        if [ -x /sbin/convertquota ]; then
380            if [ -f /quota.user ]; then
381                action $"Converting old user quota files: " \
382                    /sbin/convertquota -u / && rm -f /quota.user
383            fi
384            if [ -f /quota.group ]; then
385                action $"Converting old group quota files: " \
386                    /sbin/convertquota -g / && rm -f /quota.group
387            fi
388        fi
389        action $"Checking root filesystem quotas: " /sbin/quotacheck -nug /
390fi
391
392# check for arguments passed from kernel
393
394update_boot_stage RCmountfs
395
396# Remount the root filesystem in specified mode
397state=`awk '/(^\/dev\/root| \/ )/ { print $4 }' /proc/mounts`
398newstate=`awk '/^#/{next} $2 == "/" {print $4 }'  /etc/fstab`
399if strstr "$cmdline" no_remount_rootfs ;then
400    action $"Staying readonly root filesystem mode : " /bin/true
401else
402    [ "$state" != "rw" ] && \
403      action $"Remounting root filesystem in specified mode($newstate): " mount -n -o remount,$newstate /
404fi
405
406if [ "$READONLY" != "yes" ]; then
407    # Clear mtab
408    (>/etc/mtab) &> /dev/null
409
410    # Remove stale backups
411    rm -f /etc/mtab~ /etc/mtab~~
412
413    # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab.
414    mount -f /
415    mount -f /proc >/dev/null 2>&1
416    mount -f /sys >/dev/null 2>&1
417    mount -f /dev/pts >/dev/null 2>&1
418    mount -f /dev/shm >/dev/null 2>&1
419    mount -f /proc/bus/usb >/dev/null 2>&1
420fi
421
422if strstr "$cmdline" hdparm ;then
423update_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 
432disk[0]=s; disk[1]=hda; disk[2]=hdb; disk[3]=hdc;
433disk[4]=hdd; disk[5]=hde; disk[6]=hdf; disk[7]=hdg; disk[8]=hdh;
434 
435 
436if [ -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
469fi
470fi
471
472# The root filesystem is now read-write, so we can now log via syslog() directly..
473if [ -n "$IN_INITLOG" ]; then
474    IN_INITLOG=
475fi
476
477update_boot_stage RCmd
478
479if [ -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
502fi
503
504if [ -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
602fi
603
604update_boot_stage RCfsck
605
606_RUN_QUOTACHECK=0
607# Check filesystems
608if [ -z "$fastboot" ]; then
609        STRING=$"Checking filesystems"
610        echo $STRING
611        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
641fi
642
643update_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.
648if [ "$READONLY" != "yes" ] ; then
649    action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1
650else
651    action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1
652fi
653
654# check remaining quotas other than root
655if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then
656        if [ -x /sbin/convertquota ]; then
657            # try to convert old quotas
658            for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do
659                if [ -f "$mountpt/quota.user" ]; then
660                    action $"Converting old user quota files: " \
661                    /sbin/convertquota -u $mountpt && \
662                        rm -f $mountpt/quota.user
663                fi
664                if [ -f "$mountpt/quota.group" ]; then
665                    action $"Converting old group quota files: " \
666                    /sbin/convertquota -g $mountpt && \
667                        rm -f $mountpt/quota.group
668                fi
669            done
670        fi
671        action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug
672fi
673
674if [ -x /sbin/quotaon ]; then
675    action $"Enabling local filesystem quotas: " /sbin/quotaon -aug
676fi
677
678# Configure machine if necessary.
679if [ -f /.unconfigured ]; then
680    if [ -x /usr/bin/plymouth ]; then
681        /usr/bin/plymouth quit
682    fi
683    if [ -x /usr/bin/system-config-keyboard ]; then
684        /usr/bin/system-config-keyboard
685    fi
686    if [ -x /usr/bin/passwd ]; then
687        /usr/bin/passwd root
688    fi
689    if [ -x /usr/sbin/system-config-network-tui ]; then
690        /usr/sbin/system-config-network-tui
691    fi
692    if [ -x /usr/sbin/timeconfig ]; then
693        /usr/sbin/timeconfig
694    fi
695    if [ -x /usr/sbin/authconfig-tui ]; then
696        /usr/sbin/authconfig-tui --nostart
697    fi
698    if [ -x /usr/sbin/ntsysv ]; then
699        /usr/sbin/ntsysv --level 35
700    fi
701
702    # Reread in network configuration data.
703    if [ -f /etc/sysconfig/network ]; then
704        . /etc/sysconfig/network
705
706        # Reset the hostname.
707        action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
708    fi
709
710    rm -f /.unconfigured
711fi
712
713# Clean out /etc.
714rm -f /fastboot /fsckoptions /forcefsck /.autofsck /halt /poweroff
715
716# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might...
717_NEED_XFILES=
718[ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1
719
720# Clean up /var
721rm -rf /var/lock/cvs/* /var/run/screen/*
722find /var/lock /var/run -type f -exec rm -f {} \;
723
724rm -f /var/lib/rpm/__db* &> /dev/null
725rm -f /var/gdm/.gdmfifo &> /dev/null
726
727# Reset pam_console permissions
728[ -x /sbin/pam_console_apply ] && /sbin/pam_console_apply -r
729
730{
731# Clean up utmp/wtmp
732>/var/run/utmp
733touch /var/log/wtmp
734chgrp utmp /var/run/utmp /var/log/wtmp
735chmod 0664 /var/run/utmp /var/log/wtmp
736if [ -n "$_NEED_XFILES" ]; then
737  >/var/run/utmpx
738  touch /var/log/wtmpx
739  chgrp utmp /var/run/utmpx /var/log/wtmpx
740  chmod 0664 /var/run/utmpx /var/log/wtmpx
741fi
742
743# Clean up various /tmp bits
744rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* \
745      /tmp/.esd/*
746rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
747       /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-*  \
748       /tmp/scrollkeeper-*  /tmp/ssh-*
749# Make ICE directory
750mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1
751chown root:root /tmp/.ICE-unix
752
753# Now turn on swap in case we swap to files.
754swapon -a
755action $"Enabling swap space: " /bin/true
756
757# Initialize the serial ports.
758if [ -f /etc/rc.serial ]; then
759        . /etc/rc.serial
760fi
761
762update_boot_stage RCusbstorage
763
764# Load usb storage here, to match most other things
765if [ -n "$needusbstorage" ]; then
766        modprobe usb-storage >/dev/null 2>&1
767fi
768
769# Adjust symlinks as necessary in /boot to keep system services from
770# spewing messages about mismatched System maps and so on.
771if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ]; then
772        ln -s -f System.map-`uname -r` /boot/System.map
773fi
774if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
775        ln -s -f System.map-`uname -r` /boot/System.map
776fi
777
778# Now that we have all of our basic modules loaded and the kernel going,
779# let's dump the syslog ring somewhere so we can find it later
780dmesg -s 131072 > /var/log/dmesg
781# Also keep kernel symbols around in case we need them for debugging
782i=5
783while [ $i -ge 0 ] ; do
784        if [ -f /var/log/ksyms.$i ] ; then
785                mv /var/log/ksyms.$i /var/log/ksyms.$(($i+1))
786        fi
787        i=$(($i-1))
788done
789if [ "$KERNELVERSION" = "2.6" ]; then
790  _ksyms=/proc/kallsyms
791else
792  _ksyms=/proc/ksyms
793fi
794(/bin/date;
795 /bin/uname -a;
796 /bin/cat /proc/cpuinfo;
797 /bin/cat /proc/modules;
798 /bin/cat ${_ksyms}) >/var/log/ksyms.0
799# create the crash indicator flag to warn on crashes, offer fsck with timeout
800touch /.autofsck
801kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1
802} &
803if [ "$PROMPT" != "no" ]; then
804   /sbin/getkey i && touch /var/run/confirm
805fi
806wait
807
808#
809if [ -x /usr/bin/plymouth ]; then
810    /usr/bin/plymouth --sysinit
811fi
812   
Note: See TracBrowser for help on using the repository browser.