home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenStep 3.3J
/
os33j.iso
/
private
/
etc
/
rc.standard
< prev
next >
Wrap
Text File
|
1995-01-19
|
19KB
|
595 lines
#!/bin/sh -u
#
# This is the multi-user startup script.
#
# 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.
#
# Avoid bailing out on ^C's. This is needed both for security reasons
# as well as for the "Press Control-C to continue without a network"
# interaction (under ifconfig in rc.net) to function properly.
#
trap "/bin/true" 2
#
# 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
fbshow -B -E
fbshow -B -I "Initializing system" -z 9
# Are we booting from a CD-ROM? If so, switch over to /etc/rc.cdrom.
if [ -d /NextCD -a -f /private/etc/rc.cdrom ]; then
/bin/sh /private/etc/rc.cdrom $1
(echo "CD-ROM boot procedure complete.") >>/dev/console
/etc/halt -e
exit 0
fi
# Start the Mach network message server, which forwards Mach IPC over the
# network and provides a name-to-port mapping service.
# We need to start the nmserver here because any of Config's device drivers
# may need to register themselves with the name server. Unfortuntely, the
# network isn't ready yet, but that's OK since we tell the nmserver to
# reinitialize its network code later in rc.net.
if [ -f /usr/etc/nmserver ]; then
/usr/etc/nmserver -nonet >/dev/console 2>&1
fi
# Configure kern-loaded drivers - not on 68k (driverkit only)
if [ `/usr/bin/arch` != m68k -a -f /usr/etc/driverLoader ]; then
(echo "Configuring Device Drivers") >/dev/console
fbshow -B -I "Configuring drivers" -z 14
/usr/etc/driverLoader a >/dev/console 2>&1
fi
for i in /dev/nrst*
do
if [ -c $i ]; then
/usr/etc/stblocksize $i
(echo "Setting tape block size for $i") > /dev/console
fi
done
#
# Configure network & hostname
#
fbshow -B -I "Configuring network" -z 18
sh /etc/rc.net -h >/dev/console
#
# Determine if the network is up by looking for any non-loopback
# internet network interfaces.
#
if ifconfig -a | grep -v "127.0.0.1" | grep -v "0.0.0.0" | grep -s inet; then
NETWORKUP=-YES-
else
NETWORKUP=-NO-
fi
# Print out an appropriate message. MESSAGE is used later in the log.
if [ $1x = autobootx ]; then
# (echo Automatic reboot in progress...) >/dev/console
MESSAGE="Reboot"
else
(echo Multiuser startup in progress...) >/dev/console
MESSAGE="Multi-user startup"
fi
# Check for and mount swapdisks.
sh /etc/rc.swap $1
# Mount local filesystems (according to /etc/fstab).
mount -vat 4.3 >/dev/console 2>&1
# Display a message in the iconic boot window.
fbshow -B -I "Checking system files" -z 23
# Attempt to recover the passwd file, if needed. This procedure is
# primarily historical and makes sense only when the passwd file is edited
# using the vipw command.
if [ -s /etc/ptmp ]; then
if [ -s /etc/passwd ]; then
(echo 'Passwd file conflict with ptmp:') >/dev/console
ls -l /etc/passwd /etc/ptmp >/dev/console
(echo 'Moving ptmp to ptmp.save.') >/dev/console
mv -f /etc/ptmp /etc/ptmp.save
else
(echo 'Passwd file recovered from ptmp.') >/dev/console
mv /etc/ptmp /etc/passwd
fi
elif [ -r /etc/ptmp ]; then
(echo 'Removing passwd lock file') >/dev/console
/bin/rm -f /etc/ptmp
fi
# Start the virtual memory system.
/usr/etc/mach_swapon -av >/dev/console 2>&1
(echo -n 'Cleaning up:') >/dev/console
# If the shutdown command was used to shut the system down, the file
# /etc/nologin may have been created to prevent users from logging in.
# Remove it so that logins are enabled when the system comes up.
/bin/rm -f /etc/nologin
(echo -n ' /etc/nologin') >/dev/console
# Reset pseudo-terminals (ptys) to their default states.
/usr/etc/chown root.tty /dev/tty[pqrs]*
/bin/chmod 666 /dev/tty[pqrs]*
(echo -n ' ptys') >/dev/console
# Reset permissions and ownership of raw live floppy devices.
# Loginwindow changes these to be owned by the logged in user.
/usr/etc/chown root.operator /dev/rfd[01]b
/bin/chmod 660 /dev/rfd[01]b
(echo -n ' floppy devices') >/dev/console
# Recover files being edited by ex, vi, or e when the system was restarted.
(cd /tmp; /usr/lib/ex3.7preserve -a)
(echo -n ' editors') >/dev/console
# Clean out /tmp.
(cd /tmp; find . ! -name . ! -name lost+found ! -name quotas \
-exec rm -r - {} \; )
(echo -n ' /tmp') >/dev/console
# Clear empty subdirectories of /Net.
(cd /private/Net; find . -xdev ! -name . -type d -exec rmdir {} \;)
# Clear symlinks from /Net, too.
(cd /private/Net; find . -xdev ! -name . -type l -exec rm {} \;)
(echo -n ' /Net') >/dev/console
(echo '.') >/dev/console
# Syslog must be started before daemons are launched from rc.local.
# This allows appropriate log messages to find their way to the console.
(echo -n Starting early daemons:) >/dev/console
fbshow -B -I "Starting background services" -z 27
if [ -f /usr/etc/syslogd -a -f /etc/syslog.conf ]; then
/bin/rm -f /dev/log
# If you want a timestamp to be logged periodically,
# modify the invocation of syslogd below. For example,
# for a half-hourly timestamp, add the argument "-m30".
/usr/etc/syslogd && (echo -n ' syslogd') >/dev/console
fi
(echo '.') >/dev/console
# Read the configuration information set by the HostManager application.
. /etc/hostconfig
# Set up NIS domain.
if [ "${YPDOMAIN=-NO-}" != "-NO-" -a $NETWORKUP = "-YES-" ]; then
(echo "Setting NIS domainname to $YPDOMAIN") >/dev/console
domainname $YPDOMAIN >/dev/console 2>&1
fi
# Rpc and net services are the minimal set needed to use the network.
(echo -n 'Starting RPC and network services:') >/dev/console
# Start the Mach network message server, which forwards Mach IPC over the
# network and provides a name-to-port mapping service.
#
#if [ -f /usr/etc/nmserver ]; then
# /usr/etc/nmserver & >/dev/console 2>&1
# (echo -n ' nmserver') >/dev/console
#fi
# portmap converts Sun RPC program numbers into IP port numbers.
if [ -f /usr/etc/portmap ]; then
/usr/etc/portmap && (echo -n ' portmap') >/dev/console
fi
# Turn on IP routing. If an explicit route is specified (the '*'
# clause), either an IP address must be used or the router's hostname
# and IP address must be specified in the /etc/hosts file.
# Set the 'q' (quiet) flag by default to avoid broadcasting routes
# all over the place. [This should probably be an option.]
case ${ROUTER=-NO-} in
-ROUTED-)
if [ -f /usr/etc/routed -a $NETWORKUP = "-YES-" ]; then
/usr/etc/routed -q && (echo -n ' routed') >/dev/console
fi
;;
-NO-)
;;
*)
if [ -f /usr/etc/route ]; then
/usr/etc/route add default $ROUTER 1 >/dev/console 2>&1
fi
;;
esac
# Start up the netinfo daemons. This will only complete when the
# local domain has bound to its parent domain, if it has a parent
# (that is, if the machine is on a NetInfo network). The message:
#
# Still searching for parent network administration (NetInfo) server.
# Please wait, or press 'c' to continue without network user accounts.
# See your system administrator if you need help.
#
# comes from the local domain's netinfod; typically, you can wait a minute
# or two and the local domain will eventually find a parent. As the
# message says, the system is still searching for a parent server.
# Typing 'c' aborts that search, which is probably not what you want.
# (You're most likely to see this message on a network-wide NetInfo server.)
#
# If you would like to customize this message to include the name or
# telephone number of a network administrator, edit the text of the
# message in /usr/lib/NextStep/Resources/English.lproj/NetInfo.strings,
# or its equivalent for your usual boot language.
if [ -f /usr/etc/nibindd ]; then
fbshow -B -I "Starting network services" -z 32
/usr/etc/nibindd && (echo -n ' netinfo') >/dev/console 2>&1
fi
# If we are in an NIS domain, start up the appropiate services.
if [ "$YPDOMAIN" != "-NO-" -a $NETWORKUP = "-YES-" ]; then
fbshow -B -I "Starting YP services" -z 36
# ypserv is run on NIS servers - machines with an /etc/yp/XXX dir
if [ -f /usr/etc/ypserv -a -d /etc/yp/$YPDOMAIN ]; then
/usr/etc/ypserv && (echo -n ' ypserv') >/dev/console
fi
if [ -f /usr/etc/ypbind ]; then
/usr/etc/ypbind && (echo -n ' ypbind') >/dev/console
fi
fi
# The lookup daemon, lookupd, provides information to client programs
# through the standard C library (such as gethostbyname()). It obtains
# the information from various network services: NetInfo, DNS (also called
# the Domain Name Service - named - and BIND), and NIS.
if [ -f /usr/etc/nibindd -a -f /usr/etc/lookupd ]; then
fbshow -B -I "Starting naming services" -z 41
/usr/etc/lookupd && (echo -n ' lookupd') >/dev/console
fi
# Start up time service. If you're doing any sort of network file
# access, be sure NTP is enabled and properly configured, or you may
# see very strange errors and file consistency problems.
#
# NeXT's ntpd has been modified to acquire the NTP server
# configuration from NetInfo (the /locations/ntp directory).
case ${TIME=-AUTOMATIC-} in
-AUTOMATIC-)
if [ -f /usr/etc/ntpd -a $NETWORKUP = "-YES-" ]; then
# Synchronize our clock to the network's time.
/usr/etc/ntp -F >/dev/null
# Fire off ntpd to keep the clock in sync.
/usr/etc/ntpd && (echo -n ' ntpd') >/dev/console
fi
;;
-NO-)
;;
*)
;;
esac
# biod is the NFS asynchronous block I/O daemon, which implements
# NFS read-ahead and write-behind caching on NFS clients.
if [ -f /usr/etc/biod -a $NETWORKUP = "-YES-" ]; then
fbshow -B -I "Starting I/O services" -z 45
/usr/etc/biod 4 && (echo -n ' biod') >/dev/console
fi
(echo '.') >/dev/console
# Mount remote filesystems.
fbshow -B -I "Mounting file systems" -z 50
(echo 'Mounting remote filesystems') >/dev/console
mount -at nfs >/dev/console 2>&1
fbshow -B -I "Starting system services" -z 54
# Fileservice daemons are needed to import and export filesystems.
(echo -n 'Starting file service daemons:') >/dev/console
# If AppleTalk (EtherTalk) is desired, start up the AppleTalk daemon.
if [ -f /usr/etc/atalkd ]; then
fbshow -B -I "Starting AppleTalk" -z 59
if /usr/etc/atalkd >/dev/console 2>&1; then
(echo -n ' atalkd') >/dev/console
fi
fi
# Start the automounter only if /Net is a directory that is not
# a symlink (symlinks to directories qualify as directories to test's
# -d operation).
if [ -h /Net -o -f /Net ]; then
(echo "Warning: NeXT NFS automounter did not run.") >/dev/console
else
if [ -f /usr/etc/autonfsmount -a $NETWORKUP = "-YES-" ]; then
# The autonfsmounter will attempt a remount every 10 seconds,
# cache names for 12 hours [43200 seconds], mount things in
# /private/Net, ignore any NIS auto.master map, be triggered
# by references in the /Net directory, and use the fstab
# map (i.e., look in the mounts database -- /mounts in NetInfo,
# for example) to locate remote filesystems.
fbshow -B -I "Starting automounter" -z 63
/usr/etc/autonfsmount -tm 10 -tl 43200 \
-a /private -m /Net -fstab \
&& (echo -n ' autonfsmount') >/dev/console 2>&1
fi
fi
# If exportfs finds something to export (either using /etc/exports or the
# exports NetInfo directory), then start the NFS daemons (which service
# NFS requests) and the mount server (which services NFS mount requests).
if [ -f /usr/etc/exportfs ]; then
# Clear the table of exported filesystems before running exportfs.
> /etc/xtab
fbshow -B -I "Exporting filesystems" -z 68
if /usr/etc/exportfs -a >/dev/console 2>&1; then
# There is no "right" number of nfsd's. Infrequently-accessed
# servers can get by with 4 or fewer. 8 is not excessive for
# heavily-loaded servers.
/usr/etc/nfsd 6 && (echo -n ' nfsd') >/dev/console
/usr/etc/rpc.mountd && (echo -n ' rpc.mountd') >/dev/console 2>&1
fi
fi
# If AppleShare is desired, start up the AppleShare daemon.
if [ -f /usr/etc/ashared ]; then
fbshow -B -I "Starting AppleShare" -z 72
if /usr/etc/ashared >/dev/console 2>&1; then
(echo -n ' ashared') >/dev/console
fi
fi
# If we are a Network Master become a BOOTP and BOOTPARAM server. This is
# the only thing that depends on the value of NETMASTER from /etc/hostconfig.
if [ "${NETMASTER=-NO-}" = "-YES-" ]; then
# If /etc/bootptab file exists, become a BOOTP server. Note
# that bootpd gets information from /etc/bootptab even when
# NetInfo is running (the per-client information comes from
# NetInfo; the global information comes from /etc/bootptab).
if [ -f /usr/etc/bootpd -a -f /etc/bootptab ]; then
/usr/etc/bootpd && (echo -n ' bootpd') >/dev/console
fi
# bootparamd doesn't need a flat file.
if [ -f /usr/etc/rpc.bootparamd ]; then
/usr/etc/rpc.bootparamd && \
(echo -n ' rpc.bootparamd') >/dev/console
fi
fi
# Run the arpLoader to make permanent ARP entries for SPARC clients.
# Does nothing if this system is not a NetInstall server or if the
# server has no SPARC clients.
if [ -f /usr/etc/arpLoader ]; then
/usr/etc/arpLoader
fi
(echo '.') >/dev/console
# Network daemons provide service to the outside world.
(echo -n Starting network daemons:) >/dev/console
fbshow -B -I "Starting network daemons" -z 77
# Run the Internet server daemon.
if [ -f /usr/etc/inetd ]; then
/usr/etc/inetd && (echo -n ' inetd') >/dev/console
fi
# Remove junk from the outbound mail queue directory and start up
# the sendmail daemon. /usr/spool/mqueue is assumed here even though
# it can be changed in the sendmail configuration file.
#
# sendmail is started even if there's no configuration file
# in /etc/sendmail/sendmail.cf. sendmail can find a configuration file
# based on information in NetInfo (the sendmail.cf property in the
# /locations/sendmail directory). If no sendmail configuration file
# exists, sendmail will exit with an appropriate error message.
#
# Any messages which end up in the queue, rather than being delivered
# or forwarded immediately, will be processed once each hour.
if [ -f /usr/lib/sendmail ]; then
(cd /usr/spool/mqueue; rm -f nf* lf*)
/usr/lib/sendmail -bd -q1h 2>/dev/console && \
(echo -n ' sendmail') >/dev/console
fi
# lpd is the Berkeley line printer daemon.
if [ -f /usr/lib/lpd ]; then
rm -f /dev/printer
/usr/lib/lpd && (echo -n ' printer') >/dev/console
fi
# Start an SNMP agent if configured to do so.
if [ -f /usr/etc/snmpd ]; then
if /usr/etc/snmpd -N >/dev/console 2>&1; then
(echo -n ' snmpd') >/dev/console
fi
fi
(echo '.') >/dev/console
# NeXT services support the application environment
(echo -n 'Starting NeXT services:') >/dev/console
fbshow -B -I "Starting NeXT services" -z 81
# The pasteboard server is used by the AppKit.
if [ -f /usr/etc/pbs ]; then
/usr/etc/pbs && (echo -n ' pbs') >/dev/console
fi
# exec_faxes starts up any appropriate fax modem daemons.
if [ -f /usr/lib/NextPrinter/exec_faxes ]; then
/usr/lib/NextPrinter/exec_faxes && (echo -n ' exec_faxes') >/dev/console
fi
# If ISDN Networking is desired, start up the PhoneConnector in daemon mode.
/usr/bin/niutil -read . /localconfig/ISDN/Networking >/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ -f /NextAdmin/PhoneConnector.app/PhoneConnector ]; then
/NextAdmin/PhoneConnector.app/PhoneConnector -Daemon YES && \
(echo -n ' PhoneConnector') >/dev/console
fi
fi
(echo '.') >/dev/console
# Customizations to the startup sequence which load protocol
# stacks such as AppleTalk should be placed in /etc/rc.local.protocols
# This allows them to load before NetWare and get a right of first
# refusal before NetWare on all incoming packets. When used with 802.3
# framing, NetWare consumes all incoming packets and does not
# pass any on to protocol stacks loaded after NetWare.
if [ -f /etc/rc.local.protocols ]; then
sh /etc/rc.local.protocols $1
fi
# If NetWare Networking is desired, start it.
( /usr/bin/niutil -read . /localconfig/NetWare | \
/usr/bin/egrep 'enable.+YES' ) >/dev/null 2>&1
if [ $? -eq 0 ]; then
# Don't start NetWare unless there is at least one network interface up
if [ -n "`ifconfig -a | grep en0 `" -o -n "`ifconfig -a | grep tr0 `" ]; then
(echo -n "Starting NetWare:") >/dev/console 2>&1
fbshow -B -I "Starting NetWare" -z 86
# Load and start the kernel server.
if [ -f /usr/lib/kern_loader/nuc/nuc_reloc ]; then
/usr/etc/kl_util -a /usr/lib/kern_loader/nuc/nuc_reloc \
>/tmp/nuc_log 2>&1
(echo -n ' nuc_reloc ') >/dev/console 2>&1
fi
if [ -f /usr/netware/bin/nucinit ]; then
/usr/netware/bin/nucinit >/dev/console 2>&1
(echo -n ' nucinit') >/dev/console 2>&1
fi
# Configure the protocol stack.
if [ -f /usr/netware/etc/npsd ]; then
/usr/netware/etc/npsd && (echo -n ' npsd') >/dev/console 2>&1
fi
# Start the Management Portal, an internal port for communicating
# with the kernel server.
if [ -f /usr/netware/bin/nwmp ]; then
/usr/netware/bin/nwmp start && (echo -n ' nwmp') >/dev/console 2>&1
fi
# Start the Netware Service Advertisement Protocol Daemon, which looks for
# NetWare servers' advertisement packets.
if [ -f /usr/netware/etc/sapd ]; then
/usr/netware/etc/sapd && (echo -n ' sapd') >/dev/console 2>&1
fi
# Start the NetWare automounter.
if [ -f /usr/etc/autoNetWaremount ]; then
/usr/etc/autoNetWaremount && (echo -n ' autoNetWaremount') \
>/dev/console 2>&1
fi
else
(echo -n 'No network interface: NetWare not started') >/dev/console 2>&1
fi
(echo '.') >/dev/console
fi
# InputManager startup procedure (Japanese)
if [ -d /NextLibrary/InputManager ]; then
(echo -n 'Starting input servers:') >/dev/console
fbshow -B -I "Starting input servers" -z 90
for i in /NextLibrary/InputManager/*
do
if [ -d $i ]; then
if [ $i = "/NextLibrary/InputManager/Resources" ]; then
continue
fi
rcfile=`basename $i`
if [ -f $i/${rcfile}.rc ]; then
sh $i/${rcfile}.rc $1
fi
fi
done
(echo '.') >/dev/console
fi
# Any customizations to the startup sequence you would like to make should
# be placed in /etc/rc.local; this way they can be preserved when your
# system is later upgraded to a new version of system software.
if [ -f /etc/rc.local ]; then
sh /etc/rc.local $1
fi
# Unlock tip lines. tip and UUCP share lock files so they don't get in
# each other's way.
if [ -d /usr/spool/uucp ]; then
rm -f /usr/spool/uucp/LCK.*
rm -f /usr/spool/uucp/LCK/LCK.*
fi
# Start standaard daemons that should always run
(echo -n Starting standard daemons:) >/dev/console
fbshow -B -I "Starting standard daemons" -z 95
# update flushes the cached blocks from the filesystem using
# the sync system call every 30 seconds. This ensures the
# disk is reasonably up-to-date in the event of a system crash.
update && (echo -n ' update') >/dev/console
# cron executes commands listed in /etc/crontab at specified times.
cron && (echo -n ' cron') >/dev/console
# accton is here for historical reasons.
# if [ -f /usr/adm/acct ]; then
# accton /usr/adm/acct && (echo -n ' accounting') >/dev/console
# fi
(echo '.') >/dev/console
# Submit a syslog note to indicate that we've successfully rebooted.
/usr/ucb/logger -t reboot -p kern.crit "$MESSAGE complete"
fbshow -B -I "Startup complete" -z 100
exit 0