#! /bin/sh
#
# boot		boot-time system configuration.
#
# Version:	@(#)boot  2.10  26-Apr-1997  miquels@cistron.nl
#
#		Copyright (C) 1994-1997 Debian Association, Inc.
#		Written by Ian Murdock <imurdock@gnu.ai.mit.edu>
#		       and Miquel van Smoorenburg <miquels@cistron.nl>
#

#
# This script desperately needs to parse a config file
# (like /etc/default/boot) instead of having to edit it directly!
#

# Time files in /tmp are kept.
TMPTIME=0
# Set to yes if you want sulogin to be spawned on bootup
SULOGIN=no
# Set to no if you want to be able to login over telnet/rlogin
# before system startup is complete (as soon as inetd is started)
DELAYLOGIN=no
# Set GMT="-u" if your system clock is set to GMT, and GMT="" if not.
GMT=""
# Set VERBOSE to "no" if you would like a more quiet bootup.
VERBOSE=yes

PATH=/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin1:/usr/bin2:/usr/bin3:
umask 022
export PATH VERBOSE

#
# Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
#
#trap ":" INT QUIT TSTP

#
# Load the keymaps *as soon as possible*
#
if [ -r /etc/kbd/default.map ]
then
  loadkeys /etc/kbd/default.map
fi

#
# Set SULOGIN to yes if you want a sulogin to be spawned from
# this script *before anything else* with a timeout, like on SCO.
#
[ "$SULOGIN" = yes ] && sulogin -t 30 $CONSOLE

  echo
  echo "Running /etc/init.d/boot..."
  echo

#
# Activate the swap device(s) in /etc/fstab. This needs to be done
# before fsck, since fsck can be quite memory-hungry.
#
#if [ -x /sbin/swapon ]
#then
#  [ "$VERBOSE" != no ] && echo "Activating swap..."
#  swapon -a 2>/dev/null
#fi

#
# Ensure that bdflush (update) is running before any major I/O is
# performed (the following fsck is a good example of such activity :).
#
#[ -x /sbin/update ] && update

#
# Remount rootfs rw (default), but do not try to change mtab because it
# is on a ro fs until the remount succeeded.  Then clean up old mtabs and
# finally write the new mtab.
#
mount -n -o remount,rw /
rm -f /etc/mtab~ /etc/nologin
: > /etc/mtab
mount -o remount,rw /
mount /proc

#
# Configure the isa plug and play boards before loading
# modules. Need to do this before loading modules to get
# a chance of configuring and starting PnP boards before
# the drivers mess all this up.
#
if [ -x /etc/init.d/isapnp ]
then
  /etc/init.d/isapnp start
fi

#
# Load the appropriate modules. This needs to be done here in case fs modules
# are needed for accessing or mounting local file systems.
#
#if [ -x /etc/init.d/modutils ]
#then
#  /etc/init.d/modutils start
#elif [ -x /etc/init.d/modules ]
#then
#  /etc/init.d/modules start
#fi

#
# Put a nologin file in /etc to prevent people from logging in before
# system startup is complete.
#
if [ "$DELAYLOGIN" = yes ]
then
  echo "System bootup in progress - please wait" > /etc/nologin
  cp /etc/nologin /etc/nologin.boot
fi

#
# Mount local file systems in /etc/fstab.
#
[ "$VERBOSE" != no ] && echo "Mounting local file systems ..."
mount -avt nonfs,noproc

# start script on floppy to adjust some files here
/mnt/startup

#
# Execute swapon command again, in case we want to swap to
# a file on a now mounted filesystem.
#
#swapon -a 2>/dev/null

#
# Set hostname.
#
hostname --file /etc/hostname

#
# 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 start
  /etc/init.d/sysklogd start
fi

#
# Now that TCP/IP is configured, mount the NFS file systems in /etc/fstab.
#
echo "Mounting remote file systems ..."
mount -a -t nfs

#
# Set and adjust the CMOS clock.
#
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.
#
if [ "$VERBOSE" != no ]
then
  echo
  echo "Local time: `date`"
  echo
fi

#
# Save the random seed.
#
/etc/init.d/urandom start

#
# Set pseudo-terminal access permissions.
#
chmod 666 /dev/tty[0-9] /dev/console
chown root.tty /dev/tty[0-9a-f] /dev/console
#
#rm -f /etc/nologin /etc/nologin.boot

