home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
private
/
etc
/
rc.boot.standard
< prev
next >
Wrap
Text File
|
1992-05-12
|
8KB
|
231 lines
#!/bin/sh -u
#
# This script sets up the machine enough to run single-user
#
# Copyright (C) 1992 by NeXT Computer, Inc. All rights reserved.
#
# Note that all "echo" commands are in parentheses so that
# the main shell does not open a tty and get its process group set.
HOME=/; export HOME
PATH=/etc:/usr/etc:/bin:/usr/bin; export PATH
iscdrom=0
(echo) > /dev/console
# Are we booting from a CD-ROM? If so, make a note of the fact.
if [ -d /NextCD ]; then
(echo "Root device is a CD-ROM. Filesystem checks skipped.") > /dev/console
iscdrom=1
fi
swapfile=/private/vm/swapfile
swapdir=/private/vm
# We must fsck here before we touch anything in the filesystems.
fsckerror=0
# Output the date for reference.
date >/dev/console
# Don't fsck if we're single-user, or if we're on a CD-ROM.
if [ $1x = singleuserx -a $iscdrom -ne 1 ]; then
(echo "Singleuser boot -- fsck not done") >/dev/console
# Ensure that the root filesystem is mounted read-write.
mount -o remount / >/dev/console
# Is there a swapfile? Print a warning if not.
if [ ! -f $swapfile ]; then
(echo "No default swapfile present!") >/dev/console
fi
elif [ $iscdrom -ne 1 ]; then
# We're neither single-user nor on a CD-ROM.
fbshow -A -B -E -I "Checking*Disk..."
(echo Checking disks) >/dev/console
# Benignly clean up ("preen") any dirty filesystems.
# fsck -p will skip disks which were properly unmounted during
# a normal shutdown.
fsck -p >/dev/console 2>&1
# fsck's success is reflected in its status.
case $? in
D86)
# No problems
;;
2)
# Request was made (via SIGQUIT, ^\) to complete fsck
# but prevent going multi-user.
(echo "Request to remain single-user received.") > /dev/console
fsckerror=1
;;
4)
# The root filesystem was checked and fixed. Let's reboot.
# Note that we do NOT sync the disks before rebooting, to
# ensure that the filesystem versions of everything fsck fixed
# are preserved, rather than being overwritten when in-memory
# buffers are flushed.
(echo "Root fixed - rebooting.") >/dev/console
reboot -q -n
;;
8)
# Serious problem was found.
(echo "Reboot failed...help!") >/dev/console
fsckerror=1
;;
12)
# fsck was interrupted by SIGINT (^C)
(echo "Reboot interrupted.") >/dev/console
fsckerror=1
;;
*)
# Some other error condition ocurred.
(echo "Unknown error in reboot fsck.") >/dev/console
fsckerror=1
;;
esac
# Ensure root filesystem is mounted read-write.
mount -o remount / >/dev/console
# Make sure the swapfile exists
if [ ! -f $swapfile ]; then
(echo -n "Creating default swapfile") >/dev/console
mkdirs -o root -g wheel -m 755 $swapdir
touch $swapfile
# Swapfile needs to have the "sticky" bit set.
chmod 1600 $swapfile
(echo " - rebooting") >/dev/console
reboot -q
fi
fi
# Read in configuration information.
. /etc/hostconfig
# Fake mount entries for root and private filesystems (i.e., ensure that
# they appear in /etc/mtab; filesystems mounted by the kernel aren't yet
# recorded in mtab).
if [ $iscdrom -ne 1 ]; then
(echo "Faking root mount entries") >/dev/console
# Clean out /etc/mtab.
> /etc/mtab
mount -f /
mount -f /private
fi
# Configure network interfaces, based on the /etc/hostconfig parameters.
# We're going to build the arguments for ifconfig, to turn on the default
# network interface. The complete command (depending on the hostconfig
# parameters) will look something like this:
#
# ifconfig en0 INETADDR netmask IPNETMASK broadcast IPBROADCAST -trailers up
#
# where the uppercase words are replaced by their respecitve hostconfig
# variables. Note that ifconfig and hostname place special meaning on
# -AUTOMATIC-.
ifconfigerror=0
# If INETADDR isn't -NO-, we'll configure the en0 interface to the
# specified IP address. If INETADDR is -AUTOMATIC-, ifconfigD87l
# broadcast a BOOTP request to determine our IP address.
if [ "${INETADDR=-AUTOMATIC-}" != "-NO-" ]; then
(echo "Configuring ethernet interface to $INETADDR") >/dev/console
# If IPNETMASK is empty, no "netmask" clause will be included in the
# ifconfig. This corresponds to the "Default" setting in HostManager's
# Local Configuration panel, and results in a network mask based on
# class of the machine's IP address. If IPNETMASK is -AUTOMATIC-,
# ifconfig will broadcast an ICMP Address Mask Request, asking the
# machines on the network to provide the netmask.
#
# Note that if you specify an explicit netmask, it will be combined
# (using the logical OR operation) with the default netmask based on
# the class of your network.
if [ -n "${IPNETMASK=}" ]; then
IFFLAGS="netmask $IPNETMASK"
else
IFFLAGS=
fi
# If IPBROADCAST is empty, no "broadcast" clause will be included
# in the ifconfig, and the default broadcast address will be used.
# The default broadcast address is obtained by performing a logical
# OR operation on our IP address and the logical NOT of the netmask.
# (E.g., an IP address 192.42.172.1 and a netmask of ffffff00 will
# yield a broadcast address of 192.42.172.255.)
if [ "${IPBROADCAST=-AUTOMATIC-}" != "-AUTOMATIC-" -a \
-n "${IPBROADCAST}" ]; then
IFFLAGS="$IFFLAGS broadcast $IPBROADCAST"
(echo "Setting broadcast address to $IPBROADCAST.") > /dev/console
else
(echo "Using default broadcast address") > /dev/console
fi
fbshow -A -B -E -I "Checking*for*Network..."
# Run ifconfig with the specified parameters, bringing the interface
# up (and not using trailers!).
ifconfig en0 $INETADDR $IFFLAGS -trailers up >/dev/console 2>&1
ifconfigerror=$?
# If we got an error, don't bother trying to do automatic hostname
# acquisition (if that's specified).
if [ $ifconfigerror -ne 0 -a \
"${HOSTNAME=-AUTOMATIC-}" = "-AUTOMATIC-" ]; then
HOSTNAME=-NO-
fi
else
(echo "Skipping ethernet interface configuration") >/dev/console
fi
# Turn on the loopback interface. This one's much easier...
ifconfig lo0 127.0.0.1 up
hosterror=0
# If HOSTNAME is -AUTOMATIC-, the hostname command broadcasts a BOOTP
# request to determine its hostname.
if [ "${HOSTNAME=-AUTOMATIC-}" != "-NO-" ]; then
if [ $HOSTNAME != -AUTOMATIC- ]; then
(echo "Configuring hostname to $HOSD88E") >/dev/console
fi
# hostname knows about -AUTOMATIC-
hostname $HOSTNAME >/dev/console 2>&1
hosterror=$?
else
# This is NOT the place to change your hostname. Change it
# using the HostManager application.
(echo "Setting hostname to localhost") >/dev/console
/bin/hostname localhost
fi
sync
# If booted into single-user mode from a CD-ROM, print out some hints
# about how to fake up /tmp and get to other disks.
if [ $1x = singleuserx -a $iscdrom -eq 1 ]; then
((
echo ""
echo "You are now in single-user mode while booted from a CD-ROM."
echo "Since the root disk is read-only, some commands may not work as"
echo "they normally do. In particular, commands that try to create"
echo "files in /tmp will probably fail. One way to avoid this problem"
echo "is to mount a separate hard disk or floppy on /tmp using the"
echo "mount command. For example,'/etc/mount -n /dev/fd0a /tmp' puts"
echo "/tmp on the internal floppy disk of a NeXTstation. (The -n"
echo "option prevents mount from trying to record the mount in"
echo "/etc/mtab.)"
echo ""
) > /dev/console )
fi
# Exit with error if failed above. ifconfig exits 1 if the error is
# a showstopper and 2 if it is not. The only non-showstopper is the network
# being down.
if [ $fsckerror -ne 0 -o $ifconfigerror -eq 1 -o $hosterror -ne 0 ]; then
exit 1
fi
exit 0