: "@(#)rc	6.3	4/8/87"

# Define exit status values.
EXIT_OK=0
EXIT_NO_RL=1
EXIT_NO_NET=2
EXIT_MAX=2

# Make sure daemons ignore appropriate signals.
trap "" 1 2 3

# Let our presence be known.
echo this is the /etc/rc file

# The following three variables are set from command line arguments
# supplied in the /etc/inittab line that runs this script.  They
# specify the hostname (see /etc/hosts), interface (ec0 or wb0),
# and internet address (e.g., 126.7).
HOSTNAME=$1
INTERFACE=$2
IPADDR=$3

# Get the run-level.  By convention, default actions for different
# run-levels are:
#     RUN-LEVEL		ACTION
#        0		only ttys local to system
#        1		above plus outgoing net
#        2		add remote ttys and full net
LOCAL=0
OUTNET=1
REMOTE=2
set `who -r`
if [ $# -lt 7 ]
then
    echo $0: Run-level not specified in /etc/utmp. 1>&2
    exit $EXIT_NO_RL
else
    runLevel=$7
fi

# Remove temporary NFS related file.
rm -f /tmp/nfs*

# Reset access to all pseudo ttys.  Login when invoked with -R
# will set access to appropriate setting.  This will signify
# that the pseudo tty is useable by rlogind and telnetd.
chmod 000 /dev/ttyp* /dev/ptyp*

#  Zero the logging RAM if readlr is present.
if [ -x /usr/test/sys/readlr ]
then
    /usr/test/sys/readlr -z > /dev/null
fi

# If hostname has been specified, we will attempt to configure the network
# to the degree specified by the run-level (see below).  If no hostname
# has been specified, we act as if no errors occured and ignore any network
# interfaces present.
status=$EXIT_OK
if [ $HOSTNAME ]
then
    # Define hostname if it is known.
    hostname $HOSTNAME
    # If at appropriate run-level, try to configure the network interface.
    if [ $runLevel -ge $OUTNET ]
    then
	iphostid $IPADDR
	if /etc/ifconfig $INTERFACE $HOSTNAME
	then
	    # Network is up - allow outgoing network mail.
	    if [ -x /usr/lib/sendmail -a -r /usr/lib/sendmail.cf ]
	    then
		(cd /usr/spool/mqueue; rm -f [lnx]f*)
		/usr/lib/sendmail -bd -q30m &
	    fi
	    # If at appropriate run-level, allow incoming network access.
	    if [ $runLevel -ge $REMOTE ]
	    then
		/etc/ftpd
		/etc/rwhod
		/etc/rshd
		/etc/telnetd
		/etc/rlogind
		if [ -x /usr/bin/pcistart ]
		then
		    /usr/bin/pcistart
		fi
		if [ -x /etc/portmap ]
		then
		    /etc/portmap
		fi
		if [ -x /etc/mountd ]
		then
		    /etc/mountd
		fi
		if [ -x /etc/pcnfsd /tmp ]
		then
		    /etc/pcnfsd
		fi
	    fi
	else
	    echo NO NETWORK!!!
	    status=$EXIT_NO_NET
	fi
    fi
fi

# Run /etc/rc.local if it exists.
if [ -r /etc/rc.local ]
then
    . /etc/rc.local
fi

# Print copyright notices for products installed on this system.
cat -s /copyrights/*

exit $status
