BBS水木清华站∶精华区

发信人: Hanky@FruitTea1 (骗谁啊?), 信区: Linux 
标  题: SysV init 2.6 的开机过程 (二) 附件一 
发信站: 果茶小站 (Wed May 29 21:39:12 1996) 
 
PATH="/sbin:/bin:/usr/sbin:/usr/bin" 
umask 022 
 
echo 
echo "Running /etc/init.d/boot..." 
echo 
 
# enable kerneld 
if [ -x /sbin/kerneld ]; then 
  /sbin/kerneld 
fi 
 
# 把 md 跑起来 
if [ -s /etc/mdtab -a -f /sbin/mdadd ] 
then 
  mdadd -ar 
fi 
 
echo "Activating swap..." 
swapon -a 2>/dev/null 
 
# Ensure that bdflush (update) is running before any major I/O is 
# performed (the following is a good example of such activity :). 
update & 
 
# Check the integrity of all file systems (if not a fastboot). 
if [ ! -f /fastboot ] 
then 
  # Ensure that root is quiescent and read-only before fsck'ing. 
  mount -n -o remount,ro / 
  if [ $? = 0 ] 
  then 
    echo "Checking file systems..." 
    fsck -A -a 
    # If there was a failure, drop into single-user mode. 
    # 
    # NOTE: "failure" is defined as exiting with a return code of 
    # 2 or larger.  A return code of 1 indicates that file system 
    # errors were corrected but that the boot may proceed. 
    if [ $? -gt 1 ] 
    then 
      # Surprise! Re-directing from a HERE document (as in 
      # "cat << EOF") won't work, because the root is read-only. 
      echo 
      echo "fsck failed.  Please repair manually and reboot.  Please note" 
      echo "that the root file system is currently mounted read-only.  To" 
      echo "remount it read-write:" 
      echo 
      echo "   bash# mount -n -o remount,rw /" 
      echo 
      echo "CONTROL-D will reboot the system." 
      echo 
      # Start a single user shell on the console 
      /sbin/sulogin /dev/console 
      sync 
      reboot 
    fi 
    echo 
  else 
    echo "*** ERROR!  Cannot fsck because root is not read-only!" 
    echo 
  fi 
else 
  echo "*** Fast boot ... skipping disk checks" 
  echo 
fi 
 
# Remount the root file system in read-write mode. 
mount -n -o remount,rw / 
 
# Load the appropriate modules. 
if [ -x /etc/init.d/modules ] 
then 
  /etc/init.d/modules 
fi 
 
# Remove /etc/mtab*, /etc/rmtab, /etc/nologin and /fastboot. 
rm -f /etc/mtab* /etc/nologin /fastboot /etc/rmtab 
 
# update /etc/psdatabase 
psupdate 2> /dev/null 
# or 
#ps -U 2> /dev/null 
 
# Mount local file systems in /etc/fstab. 
echo "Mounting local file systems..." 
mount -avt nonfs 
 
# Execute swapon command again, in case we want to swap to 
# a file on a now mounted filesystem. 
swapon -a 2>/dev/null 
 
# Setup the network interfaces. Note that /var/run and /var/lock 
# are cleaned up after this, so don't put anything in the "network" 
# script that leave a pidfile or a lockfile. 
if [ -x /etc/init.d/network ] 
then 
  /etc/init.d/network 
fi 
 
# Set hostname. 
# If there's no /etc/HOSTNAME, fall back on this default: 
if [ ! -r /etc/HOSTNAME ]; then 
   echo "Henry.Dorm10.NCTU.edu.tw" > /etc/HOSTNAME 
fi 
cat /etc/HOSTNAME | cut -f1 -d . > /etc/hostname 
hostname --file /etc/hostname 
 
# Now that TCP/IP is configured, mount the NFS file systems in /etc/fstab. 
echo "Mounting remote file systems..." 
mount -a -t nfs 
 
# Update all the shared library links automatically 
echo "Update /etc/ld.so.cache and all the shared library links." 
/sbin/ldconfig 
 
# Set GMT="-u" if your system clock is set to GMT, and GMT="" 
# if not. 
GMT="" 
# Set and adjust the CMOS clock. 
clock -s $GMT 
if [ ! -f /etc/adjtime ] 
then 
  echo "0.0 0 0.0" > /etc/adjtime 
fi 
clock -a $GMT 
 
# Now that /usr/lib/zoneinfo should be available, announce the local time. 
echo 
echo "Local time: `date`" 
echo 
 
# Wipe /tmp (and don't erase `lost+found', `quota.user' or `quota.group')! 
# Note that files _in_ lost+found _are_ deleted. 
echo -n "Cleaning up /tmp, /var/run and /var/lock... " 
( cd /tmp && \ 
  find . \ 
  ! -name .\ 
  ! \( -name lost+found -uid 0 \) \ 
  ! \( -name quota.user -uid 0 \) \ 
  ! \( -name quota.group -uid 0 \) \ 
    -depth -exec rm -rf -- {} \; ) 
# Clean up any stale locks. 
( cd /var/lock && find . -type f -exec rm -f -- {} \; ) 
# Clean up /var/run and create /var/run/utmp so that we can login. 
( cd /var/run && find . ! -type d -exec rm -f -- {} \; ) 
 > /var/run/utmp 
echo "done." 
 
# Run the package-specific boot scripts in /etc/rc.boot. 
run-parts /etc/rc.boot 
# Set pseudo-terminal access permissions. 
chmod 666 /dev/tty[pqrstuvwxyzabcde]* 
chown root.tty /dev/tty[pqrstuvwxyzabcde]* 
 
# Setup the /etc/issue.net to reflect the current kernel level: 
cat /etc/issue > /etc/issue.net 
uname -a >> /etc/issue.net 
echo >> /etc/issue.net 
 
touch /etc/motd 
 
# and startup powerd 
echo "Start up the genpowerd" ; /sbin/genpowerd /dev/UPS henry 
 

BBS水木清华站∶精华区