home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenStep 4.2
/
Openstep-4.2-Intel-User.iso
/
private
/
etc
/
rc.boot.standard
< prev
next >
Wrap
Text File
|
1996-02-27
|
4KB
|
157 lines
#!/bin/sh -u
#
# This script sets up the machine enough to run single-user
#
# Copyright (C) 1993 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.
#
# Initialize the path to be used and inherited by all the commands herein
#
if [ -f /.path ]; then
. /.path
else
PATH=/usr/ucb:/bin:/usr/bin:/etc:/usr/etc; export PATH
HOME=/; export HOME
fi
iscdrom=0
(echo) >> /dev/console
# Start with some -- any! -- reasonable hostname
hostname localhost
# Are we booting from a CD-ROM? If so, make a note of the fact.
if [ -d /NextCD -a -f /private/etc/rc.cdrom ]; then
(echo "Root device is mounted read-only.") >>/dev/console
(echo "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.
# Erase the rom's old-style login panel
fbshow -B -E
fbshow -B -I "Checking disk" -z 5
(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
0)
# 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 "Setting up root mount entries") >>/dev/console
# Clean out /etc/mtab.
> /etc/mtab
mount -f /
mount -f /private
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. (The -n option prevents mount"
echo "from trying to record the mount in /etc/mtab.)"
echo ""
) >> /dev/console )
fi
# Exit with error if failed above.
if [ $fsckerror -ne 0 ]; then
exit 1
fi
exit 0