]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - rc.d/rc.sysinit
- merge from TOTALNEW branch (see NEWS for more info)
[projects/rc-scripts.git] / rc.d / rc.sysinit
index 3c05249c4969451376df4eb8cd3e07c42fc3be96..a2e4a698bb6ad7035eeef9b01c98f0b265e0a2a2 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # /etc/rc.d/rc.sysinit - run once at boot time
-# $Id: rc.sysinit,v 1.30 1999/09/28 14:23:07 kloczek Exp $
+# $Id: rc.sysinit,v 1.78 2001/05/15 16:03:36 baggins Exp $
 #
 # Taken in part from Miquel van Smoorenburg's bcheckrc.
 # Changes:      Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
@@ -12,7 +12,7 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin
 export PATH
 
 # NLS
-if [ -f /etc/sysconfig/i18n ]; then
+if [ -r /etc/sysconfig/i18n ]; then
        . /etc/sysconfig/i18n
        [ -n "$LANG" ] && export LANG || unset LANG
        [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
@@ -26,12 +26,11 @@ if [ -f /etc/sysconfig/i18n ]; then
        [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
 fi
 
-
 # Read functions
 . /etc/rc.d/init.d/functions
 
 # Read network config data.
-if [ -f /etc/sysconfig/network ]; then
+if [ -r /etc/sysconfig/network ]; then
        . /etc/sysconfig/network
 else
        NETWORKING=no
@@ -39,7 +38,7 @@ else
 fi
 
 # Read system config data.
-if [ -f /etc/sysconfig/system ]; then
+if [ -r /etc/sysconfig/system ]; then
        . /etc/sysconfig/system
 else
        RUN_SULOGIN_ON_ERR=yes
@@ -50,26 +49,114 @@ else
        CONSOLE_LOGLEVEL=1
        LOAD_SOUND=yes
        SET_SLINKS=yes
+       RUN_LDCONFIG=yes
+fi
+
+# Print welcome message
+nls "\t\t\t%sPowered by %sPLD GNU/Linux%s" "$(termput setaf 6)" "$(termput setaf 2)" "$(termput setaf 7)"
+if is_yes "$PROMPT"; then
+       nls -n "\t\t     Press %sI%s to enter interactive startup." "$(termput setaf 1)" "$(termput setaf 7)"
+       echo
+       sleep 1
+fi
+
+# we need /proc mounted before everything
+mount -n -o gid=17 -t proc /proc /proc
+
+# /dev must be also mounted before everything but only if we want use them ;-)
+if is_yes "$MOUNT_DEVFS"; then
+    run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
+fi
+
+# set up devfsd
+if is_yes "$RUN_DEVFSD"; then
+    if [ -x /sbin/devfsd -a -f /etc/devfsd.conf ]; then
+           run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
+    fi
 fi
 
 # Set console loglevel
-/sbin/loglevel $CONSOLE_LOGLEVEL
+/bin/dmesg -n $CONSOLE_LOGLEVEL
+
+# Configure Linux kernel
+run_cmd "Configuring kernel parameters" /sbin/sysctl -p /etc/sysctl.conf
+
+# Set the system clock.
+ARC=0
+SRM=0
+UTC=0
+
+if [ -f /etc/sysconfig/clock ]; then
+   . /etc/sysconfig/clock
+
+   # convert old style clock config to new values
+   if [ "${CLOCKMODE}" = "GMT" ]; then
+      UTC=true
+   elif [ "${CLOCKMODE}" = "ARC" ]; then
+      ARC=true
+   fi
+fi
+
+if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+   ARC=true
+fi
+
+CLOCKDEF=""
+CLOCKFLAGS="--hctosys"
+
+case "$UTC" in
+   yes|true)
+    CLOCKFLAGS="$CLOCKFLAGS --utc";
+    CLOCKDEF="$CLOCKDEF (utc)";
+  ;;
+   *)
+    CLOCKFLAGS="$CLOCKFLAGS --localtime";
+    CLOCKDEF="$CLOCKDEF (local)";
+  ;;
+esac
+
+case "$ARC" in
+     yes|true)
+        CLOCKFLAGS="$CLOCKFLAGS -A";
+        CLOCKDEF="$CLOCKDEF (arc)";
+     ;;
+esac
+case "$SRM" in
+     yes|true)
+        CLOCKFLAGS="$CLOCKFLAGS -S";
+        CLOCKDEF="$CLOCKDEF (srm)";
+     ;;
+esac
+
+# Check if timezone definition is available
+if [ -e /etc/localtime ] ; then
+       if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+               show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
+       fi
+else
+       TIME_SETUP_DELAYED=yes
+fi
 
 # Start up swapping.
-run_cmd "`nls "Activating swap partitions"`" swapon -a
+run_cmd "Activating swap partitions" swapon -a
 
 # Set the hostname.
-run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
+run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
 
 # Set the NIS domain name
 if [ -n "$NISDOMAIN" ]; then
-       run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
+       run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
 else
        domainname ""
 fi
 
+# Setup hdparm thing (if exists and is needed)
+if ! grep -iq nohdparm /proc/cmdline; then
+       [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
+fi
+
 if [ -f /fsckoptions ]; then
-       fsckoptions=`cat /fsckoptions`
+       fsckoptions=$(cat /fsckoptions)
 else
        fsckoptions=''
 fi
@@ -78,40 +165,44 @@ if [ -f /forcefsck ]; then
         fsckoptions="-f $fsckoptions"
 fi
 
-# we need /proc mounted before starting fsck
-mount -t proc /proc /proc
-
-# Test for NFS Root
-NFSROOT=`cat /proc/mounts | awk '{ if ($2 ~ /^\/$/ && $3 ~ /^nfs$/) print $3 }'`
-
 _RUN_QUOTACHECK=0
-if [ ! -f /fastboot ] && [ ! -n "$NFSROOT" ]; then
-       show "Checking root filesystems."; started
-       initlog -c "fsck -T -a $fsckoptions /"
-
-       rc=$?
-
-       # A return of 2 or higher means there were serious problems.
-       if [ $rc -gt 1 ]; then
-               nls "\n\n*** An error occurred during the file system check.\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
-
-               PS1="`nls "(Repair filesystem) #"`"; export PS1
-               if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
-                       sulogin
-               else
-                       /bin/sh
-               fi
+if awk '{ if ($2 ~ /^\/$/ && ( $3 ~ /^(nfs|romfs)$/ || $6 ~ /^0$/ ) ) exit 1 ; else exit 0}' /etc/fstab; then
+
+    if [ ! -f /fastboot  ]; then
+           show "Checking root filesystems."; started
+           initlog -c "fsck -C -T -a $fsckoptions /"
+
+           rc=$?
+
+           # A return of 2 or higher means there were serious problems.
+           if [ $rc -gt 1 ]; then
+                   # don't use '\n' in nls macro !
+                   echo
+                   echo
+                   nls "*** An error occurred during the file system check."
+                   nls "*** Dropping you to a shell; the system will reboot"
+                   nls "*** when you leave the shell."
+                   echo
+
+                   PS1="$(nls '(Repair filesystem)# ')"; export PS1
+                   if is_yes "$RUN_SULOGIN_ON_ERR"; then
+                           sulogin
+                   else
+                           /bin/sh
+                   fi
+
+                   run_cmd "Unmounting file systems" umount -a
+                   mount -n -o remount,ro /
+                   run_cmd "Automatic reboot in progress." reboot
+           elif [ "$rc" = "1" ]; then
+                   _RUN_QUOTACHECK=1
+           fi
+    fi
 
-               run_cmd "Unmounting file systems" umount -a
-               mount -n -o remount,ro /
-               run_cmd "Automatic reboot in progress." reboot
-       elif [ "$rc" == "1" ]; then
-               _RUN_QUOTACHECK=1
-       fi
 fi
 
 # check for arguments 
-if grep -i nopnp /proc/cmdline >/dev/null ; then
+if grep -iq nopnp /proc/cmdline; then
        PNP=
 else
        PNP=yes
@@ -119,32 +210,40 @@ fi
 
 # set up pnp 
 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
-       if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
+       if [ -n "$PNP" ] && is_yes "$RUN_ISAPNP"; then
                run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
        fi
 fi
 
+
 # Remount the root filesystem read-write.
 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
 
 # Update quotas if fsck was run on /.
-if [ X"$_RUN_QUOTACHECK" == "X1" -a -x /sbin/quotacheck ] && [ ! -n "$NFSROOT" ]; then
-        run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
+if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ]; then
+        run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vug /
 fi
 
 # /etc/nologin when starting system
 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
 
-if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
+if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
        show "Enabling Delay Login"; busy
        echo > /etc/nologin
        nls "System bootup in progress  - please wait" >> /etc/nologin
        echo >> /etc/nologin
        chmod 644 /etc/nologin
        cp -fp /etc/nologin /etc/nologin.boot
-       deltext; ok
+       ok
 fi
 
+# The root filesystem is now read-write, so we can now log via
+# syslog() directly..
+if [ -n "$IN_INITLOG" ]; then
+    IN_INITLOG=""
+fi
+    
+echo ${HOSTNAME} > /etc/HOSTNAME
 
 # Clear mtab
 >/etc/mtab
@@ -152,8 +251,11 @@ fi
 # Enter root and /proc into mtab.
 mount -f /
 mount -f /proc
+[ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb
 
-if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
+if [ ! -f /proc/modules ]; then
+       USEMODULES=
+elif ! grep -iq nomodules /proc/cmdline; then
        USEMODULES=y
 else
        USEMODULES=
@@ -163,61 +265,119 @@ fi
 rm -f /lib/modules/preferred
 rm -f /lib/modules/default
 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
if [ "$SET_SLINKS" != "no" ]; then
 if is_yes "$SET_SLINKS"; then
     # Get ready for kmod if module support in the kernel
-    if [ -z `uname -r | grep "-"` ]; then
-       # we're using a new kernel, no preferred needed
-       mver=`uname -r`
+    if [ -z $(uname -r | grep "-") ]; then
+       # we're using a new kernel, no preferred needed
+       mver=$(uname -r)
     else
-       ktag="`cat /proc/version`"
-       mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
-       if [ -n "$mtag" ]; then
-          mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[       ].*$,,'
-       fi
-       if [ -n "$mver" ]; then
-         ln -sf /lib/modules/$mver /lib/modules/default
-       fi
+       ktag="$(cat /proc/version)"
+       mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
+       if [ -n "$mtag" ]; then
+           mver=$(echo $mtag | awk ' { gsub(/\/lib\/modules\//,NIL); gsub(/.rhkmvtag/,NIL); gsub(/[     ].*$/,NIL); print $0 } ')
+       fi
+       if [ -n "$mver" ]; then
+           ln -sf /lib/modules/$mver /lib/modules/default
+       fi
     fi
- fi
-    [ -n "$mver" -a -f "/boot/module-info-$mver" ] && ln -sf /boot/module-info-$mver /boot/module-info
-    [ -n "$mver" -a -f "/boot/System.map-$mver" ] && ln -sf /boot/System.map-$mver /boot/System.map
-    run_cmd "Finding module dependencies" depmod -a -s
+    
+    [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
+       ln -sf /boot/module-info-$mver /boot/module-info
+    [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
+       ln -sf /boot/System.map-$mver /boot/System.map
+  fi
 fi
 
-# load sound modules
-if [ -n "$USEMODULES" ] && [ "$LOAD_SOUND" == "yes" ]; then
-   if grep -s -q "^alias sound" /etc/conf.modules ; then
-      run_cmd "Loading sound module" modprobe -s sound
-   fi
-   if grep -s -q "^alias midi" /etc/conf.modules ; then
-      run_cmd "Loading midi module" modprobe -s midi
-   fi
+# Run depmod if RUN_DEPMOD != "no" and:
+# a) user requested or RUN_DEPMOD="";
+# b) modules.dep is missing
+# c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
+if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
+  if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] || \
+     [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
+     [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
+     [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]; then
+       run_cmd "Finding module dependencies" depmod -a
+  fi
 fi
 
 if [ -f /proc/sys/kernel/modprobe ]; then
-       # /proc/sys/kernel/modprobe indicates built-in kmod instead
-       echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
+       if [ -n "$USEMODULES" ]; then
+               sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
+       else
+               # We used to set this to NULL, but that causes
+               # 'failed to exec' messages"
+               sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
+       fi
 fi
 
-# Add raid devices
-if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
-       show "Starting up RAID devices."; busy
-       initlog -c 'raidadd -a'
-
-       rc=$?
-       if [ $rc = 0 ]; then
-               raidrun -a
-               rc=$?
+# Load modules
+if [ -x /etc/rc.d/rc.modules ]; then
+        /etc/rc.d/rc.modules
+fi
+       
+# load sound modules
+if [ -n "$USEMODULES" ] && is_yes "$LOAD_SOUND"; then
+       if grep -s -q "^alias sound-slot-0" /etc/modules.conf ; then
+               run_cmd "Loading sound module" modprobe -s sound-slot-0
+       fi
+       if grep -s -q "^alias synth0" /etc/modules.conf ; then
+               run_cmd "Loading synthesiser module" modprobe -s synth0
        fi
+fi
+
+# Add raid devices
+if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
+
+       rc=0
+       
+       for i in $(grep "raiddev" /etc/raidtab | awk '{print $2}')
+       do
+               RAIDDEV=$(basename $i)
+               RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
+               show "Starting up RAID device %s" $RAIDDEV
+               busy
+               if [ -z "$RAIDSTAT" ]; then
+                       # Try raidstart first...if that fails then
+                       # fall back to raid0run and if that fails, too
+                       # fall back to raidadd, raidrun.
+                       RESULT=1
+                       if [ -x /sbin/raidstart ]; then
+                               /sbin/raidstart $i
+                               RESULT=$?
+                       fi
+                       if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
+                               /sbin/raid0run $i
+                               RESULT=$?
+                       fi
+                       if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
+                               /sbin/raidadd $i
+                               /sbin/raidrun $i
+                               RESULT=$?
+                       fi
+                       if [ $RESULT -gt 0 ]; then
+                               rc=1
+                               fail
+                       else
+                               ok
+                       fi
+               else
+                       ok
+               fi
+       done
 
        # A non-zero return means there were problems.
        if [ $rc -gt 0 ]; then
-               deltext
-               fail
-               nls "\n\n*** An error occurred during the RAID startup\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
-
-               PS1="`nls "(RAID Repair) #"`"; export PS1
-               if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
+               show "Starting up RAID devices."; fail
+               echo
+               echo
+               nls "*** An error occurred during the RAID startup"
+               nls "*** Dropping you to a shell; the system will reboot"
+               nls "*** when you leave the shell."
+               echo
+
+               PS1="$(nls '(RAID Repair)# ')"; export PS1
+               if is_yes "$RUN_SULOGIN_ON_ERR"; then
                        sulogin
                else
                        /bin/sh
@@ -227,23 +387,33 @@ if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
                run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
                run_cmd "Automatic reboot in progress" reboot
        fi
-       deltext
-       ok
+       show "Starting up RAID devices."; ok
+fi
+
+# Find and activate volume groups
+if [ -e /proc/lvm -a -x /sbin/vgscan -a -x /sbin/vgchange ]; then
+       run_cmd "Scanning for LVM volume groups" /sbin/vgscan && \
+       run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
 fi
 
 # Check filesystems
-if [ ! -f /fastboot ]; then
+if ! grep -q nofsck /proc/cmdline && [ ! -f /fastboot ]; then
        show "Checking filesystems."; started
-       initlog -c "fsck -T -R -A -a $fsckoptions"
+       initlog -c "fsck -C -T -R -A -a $fsckoptions"
 
        rc=$?
 
        # A return of 2 or higher means there were serious problems.
        if [ $rc -gt 1 ]; then
-               nls "\n\n*** An error occurred during the file system check.\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
-
-               PS1="`nls "(Repair filesystem) #"`"; export PS1
-               if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
+               echo
+               echo
+               nls "*** An error occurred during the file system check."
+               nls "*** Dropping you to a shell; the system will reboot"
+               nls "*** when you leave the shell."
+               echo
+
+               PS1="$(nls '(Repair filesystem)# ')"; export PS1
+               if is_yes "$RUN_SULOGIN_ON_ERR"; then
                        sulogin
                else
                        /bin/sh
@@ -252,8 +422,16 @@ if [ ! -f /fastboot ]; then
                run_cmd "Unmounting file systems" umount -a
                run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
                run_cmd "Automatic reboot in progress." reboot
-       elif [ "$rc" == "1" -a -x /sbin/quotacheck ]; then
-               run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
+       elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
+               if [ -x /sbin/convertquota ]; then
+                       if [ -f /quota.user ]; then
+                           /sbin/convertquota -u / && rm -f /quota.user
+                       fi
+                       if [ -f /quota.group ]; then
+                           /sbin/convertquota -g / && rm -f /quota.group
+                       fi
+               fi
+               run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -u -g -R -a
        fi
 fi
 
@@ -262,25 +440,102 @@ fi
 # filesystems are NOT unmounted in single user mode.
 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
 
-# set the console font
-#if [ -x /sbin/setsysfont ]; then
-#      show "Loading default system font"; busy
-#      if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
-#fi
+# Now do some workaround - encrypted filesystems couldn't have been fsck-ed
+# before mount - that's where the password is entered.
+# mount is buggy - when remounting loopback filesystem, loop=XXX
+# option is removed from /etc/mtab
+if grep -q "encryption=" /etc/fstab; then
+       show "Checking encrypted filesystems"; started
+       LOOPLIST="$(
+       grep "encryption=" /etc/fstab | grep -v 'noauto' | grep -w 'ro' |\
+       while read FILE DIR TYPE OPTS TMP1; do
+               LOOP="`cat /proc/mounts | awk '$2 == "'"$DIR"'" { print $1 }'`"
+               echo "$LOOP"
+       done
+       grep "encryption=" /etc/fstab | grep -vw 'ro\|noauto' |\
+       while read FILE DIR TYPE OPTS TMP1; do
+               LOOP="`cat /proc/mounts | awk '$2 == "'"$DIR"'" { print $1 }'`"
+               LOOPLIST="$LOOPLIST $LOOP"
+               NEWOPTS="remount,`echo "$OPTS" | sed 's#loop\(=[^,]*\)\?#loop='"$LOOP"'#'`,ro"
+               echo "$LOOP"
+               mount "$DIR" -o "$NEWOPTS"
+       done
+       )"
+       
+       initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
+       rc=$?
+
+       # A return of 2 or higher means there were serious problems.
+       if [ $rc -gt 1 ]; then
+               echo "\n\n"
+               nls "*** An error occurred during the file system check."
+               nls "*** Dropping you to a shell; the system will reboot"
+               nls "*** when you leave the shell."
+               echo
+
+               PS1="`nls '(Repair filesystem)# '`"; export PS1
+               if is_yes "$RUN_SULOGIN_ON_ERR"; then
+                       sulogin
+               else
+                       /bin/sh
+               fi
+
+               run_cmd "Unmounting file systems" umount -a
+               run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
+               run_cmd "Automatic reboot in progress." reboot
+       fi
+       
+       show "Remounting encrypted filesystems back in rw mode"; busy
+       grep "encryption=" /etc/fstab | grep -vw 'ro\|noauto' |\
+       while read FILE DIR TYPE OPTS TMP1; do
+               LOOP="`cat /proc/mounts | awk '$2 == "'"$DIR"'" { print $1 }'`"
+               NEWOPTS="remount,`echo "$OPTS" | sed 's#loop\(=[^,]*\)\?#loop='"$LOOP"'#'`,rw"
+               mount "$DIR" -o "$NEWOPTS"
+       done
+       ok
+fi
+
+# Set the clock if timezone definition wasn't available (eg. /usr not mounted)
+if is_yes "$TIME_SETUP_DELAYED"; then
+       if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+               show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
+       fi
+fi
 
 if [ -x /sbin/quotaon ]; then
        run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
 fi
 
+# Initialize the serial ports.
+if [ -f /etc/rc.d/rc.serial ]; then
+       . /etc/rc.d/rc.serial
+fi
+
+if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
+       show "Setting %s seconds for kernel reboot after panic." "$PANIC_REBOOT_TIME"; busy
+       if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME 2> /dev/null); then ok; else fail; fi
+fi
+
 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
-rm -f /var/run/utmp  
-:>/var/run/utmpx
-chown root.utmp /var/run/utmpx
-chmod 0664 /var/run/utmpx /var/log/wtmpx
+
+{
+# Clean up utmp/wtmp
+rm -f /var/run/utmp?
+if ! is_no "$NEED_XFILES" ; then
+       :>/var/run/utmpx
+       touch /var/log/wtmpx
+       chown root.utmp /var/run/utmpx /var/log/wtmpx
+       chmod 0664 /var/run/utmpx /var/log/wtmpx
+else
+       :>/var/run/utmp
+       touch /var/log/wtmp
+       chown root.utmp /var/run/utmp /var/log/wtmp
+       chmod 0664 /var/run/utmp /var/log/wtmp
+fi
 
 # Clean /tmp
-if [ "$CLEAN_TMP" == "yes" ]; then
+if is_yes "$CLEAN_TMP"; then
        rm -rf /tmp/*
 fi
 
@@ -304,61 +559,9 @@ rm -f /tmp/.X*-lock
 # Delete Postgres sockets
 rm -f /tmp/.s.PGSQL.*
 
-# Set the system clock.
-show "Setting clock"; busy
-
-ARC=0
-UTC=0
-if [ -f /etc/sysconfig/clock ]; then
-       . /etc/sysconfig/clock
-
-       # convert old style clock config to new values
-       if [ "${CLOCKMODE}" == "GMT" ]; then
-               UTC=true
-       elif [ "${CLOCKMODE}" == "ARC" ]; then
-           ARC=true
-       fi
-fi
-
-if [ -x /sbin/hwclock ]; then
-       CLOCKFLAGS="--hctosys"
-       CLOCK=/sbin/hwclock
-else
-       CLOCKFLAGS="-a"
-       CLOCK=/sbin/clock
-fi
-
-case "$UTC" in
-  yes|true)
-       CLOCKFLAGS="$CLOCKFLAGS -u";
-#      echo -n " (utc)"
-       ;;
-esac
-
-case "$ARC" in
-  yes|true)
-       CLOCKFLAGS="$CLOCKFLAGS -A";
-#      echo -n " (arc)"
-       ;;
-esac
-
-#echo -n ": "
-if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
-
-show "`nls "Date set to"` `date`"; ok
-
 # Right, now turn on swap in case we swap to files.
-show "Enabling swap space"; busy
-if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
-       deltext; ok
-else
-       deltext; fail
-fi
-
-# Initialize the serial ports.
-if [ -f /etc/rc.d/rc.serial ]; then
-       . /etc/rc.d/rc.serial
-fi
+swapon -a >/dev/null 2>&1
+run_cmd "Enabling swap space" /bin/true
 
 # If a SCSI tape has been detected, load the st module unconditionally
 # since many SCSI tapes don't deal well with st being loaded and unloaded
@@ -371,26 +574,23 @@ if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type:   Sequential-A
        fi
 fi
 
-# there could be a new kernel version.  reinit /etc/psdevtab, to be sure.
+# there could be a new kernel version.  remove old psdevtab database
 rm -f /etc/psdevtab
-#if [ -x /bin/ps ]; then
-#show "Rebuilding /etc/psdevtab database"; busy
-#if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
-#fi
-
-if [ -x /sbin/ldconfig ]; then
-run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
-fi
-
-if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
-show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
-if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
-fi
 
 # Now that we have all of our basic modules loaded and the kernel going,
 # let's dump the syslog ring somewhere so we can find it later
 dmesg > /var/log/dmesg
 chmod 640 /var/log/dmesg
 
-# Feed entropy into the entropy pool
-/etc/rc.d/init.d/random start
+# Now that we have all of our basic modules loaded and the kernel going,
+# let's dump the syslog ring somewhere so we can find it later
+kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
+} &
+if is_yes "$PROMPT"; then
+   /sbin/getkey i && touch /var/run/confirm
+fi
+wait
+echo
+
+# This must be last line !
+# vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.055328 seconds and 4 git commands to generate.