#!/sbin/sh
#Tag 0x00000f00

# Initialize/Shutdown the standard and optional network software.
#
# $Revision: 5.17 $
#
# If the IP address for this host is the default 192.0.2.1 Internet test
# address, the software is configured for loopback (standalone) mode.
# An Internet address other than the default must be chosen in order to
# configure the network properly. See the "Network Administration" chapter
# in the Network Communications Guide or details on selecting an address.
#
# NOTE: Defaults for network interface names and addresses can be changed by
# editting /etc/config/netif.options. Therefore, you don't need to edit
# this file.
#
# A daemon or subsystem is enabled if its configuration flag in the
# /etc/config directory in the "on" state.  /sbin/chkconfig is used
# to test a flag's state (see chkconfig(1M) for details). If the flag
# file is missing, the flag is considered off.
#
#	Flag		Action if On
#	network		Allow incoming & outgoing traffic. This flag can be
#			 set off if you need to isolate the machine from
#			 network without removing cables.
#	verbose		Print name of daemons as they are started & other info
#	gated		Start Cornell routing daemon instead of BSD routed
#	mrouted		Start Stanford IP multicast routing daemon
#			 (Useful only on gateways)
#	named		Start 4.3BSD Internet domain name server
#	rwhod		Start 4.3BSD rwho daemon
#	snmpd		Start Simple Network Management Protocol daemon
#	timed		Start 4.3BSD time synchronization daemon
#	timeslave	Start SGI time synchronization daemon
#	hypernet	Initialize HyperNET controller and routes
#	routed		Start 4.3BSD RIP routing daemon
#	rtnetd		Initialize preemptable networking for real-time use
#	ipfilterd	Enable SGI IP Packet Filtering daemon
#
# The following flags are installed only in the optional products:
#
#	nfs		Start NFS daemons, mount NFS filesystems
#	automount	Start the NFS automounter daemon
#	lockd		Start the NFS lock and status daemons
#	pcnfsd		Start the PC-NFS server daemon
#	rarpd		Start the Reverse ARP daemon
#	snetd		Start the DLPI daemon - snetd
#	yp		Enable NIS, start ypbind daemon
#	ypserv		If yp is on, become a NIS server
#	ypmaster	If yp is on, become the NIS master; start passwd server
#			 (ypserv should be on, too)
#	4DDN		Initialize 4DDN (DECnet connectivity) software
#
# Site-dependent options for daemons belong in "options" files in /etc/config.
# Certain daemons require options so their options file must contain valid
# information. See the daemon's manual page in section 1M for details on
# valid options. If this host is on networks that use subnetting, add the
# appropriate 'netmask' to the ifconfig-*.options files (see ifconfig(1M) for
# details on netmasks).
#
#	File			Status
#	automount.options	optional
#	biod.options		optional
#	gated.options		optional
#	ifconfig-1.options	optional    (for primary network interface)
#	ifconfig-2.options	optional    (for 1st gateway network interface)
#	ifconfig-3.options	optional    (for 2nd gateway network interface)
#	ifconfig-4.options	optional    (for 3rd gateway network interface)
#	ifconfig-hy.options	optional    (for HyperNET interface)
#	inetd.options		optional
#	lockd.options		optional
#	mrouted.options		optional
#	named.options		optional
#	netif.options		optional    (to select different primary &
#					     gateway interfaces, etc.)
#	nfsd.options		optional
#	portmap.options		optional
#	rarpd.options		optional
#	routed.options		optional
#	rpc.passwd.options	optional
#	rtnetd.options		optional
#	rwhod.options		optional
#	snetd.options		optional
#	snmpd.options		optional
#	timed.options		optional
#	timeslave.options	required
#	ypbind.options		optional
#	ypserv.options		optional
#
# In addition, site-dependent configuration commands to add static routes
# and publish arp entries should be put in a separate shell script called
# /etc/init.d/network.local. Make symbolic links in /etc/rc0.d and
# /etc/rc2.d to this file to have it called during system startup
# and shutdown:
#    ln -s /etc/init.d/network.local /etc/rc0.d/K39network # before network
#    ln -s /etc/init.d/network.local /etc/rc2.d/S31network # after network
# The script is called with one argument ("start" or "stop").
#
#
# Copyright 1988-1993 Silicon Graphics, Inc.
# All rights reserved.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
# the contents of this file may not be disclosed to third parties, copied or
# duplicated in any form, in whole or in part, without the prior written
# permission of Silicon Graphics, Inc.
#
# RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
# and Computer Software clause at DFARS 252.227-7013, and/or in similar or
# successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
# rights reserved under the Copyright Laws of the United States.


CONFIG=/etc/config
IS_ON=/sbin/chkconfig

# The verbose flag controls the printing of the names of daemons as they
# are started and the printing of NFS-mounted filesystem names as they are
# mounted and unmounted.

if $IS_ON verbose ; then
    ECHO=echo
    VERBOSE=-v
    LOGGER='lfmt -l network -s warn'
else		# For a quiet startup and shutdown
    ECHO=:
    VERBOSE=
    LOGGER='lfmt -l network -s warn -G 3'
fi

PATH=$PATH:/usr/etc/yp:.
NFS=/usr/etc
YPDOMFILE=/var/yp/ypdomain
YPSETDOM=/usr/bin/domainname
IFCONFIG=/usr/etc/ifconfig
ROUTE=/usr/etc/route
MSGTIME=10			# number of seconds to display error message
localhost=127.0.0.1		# definition of 'localhost' in /etc/hosts


nfs_on () {
    $IS_ON nfs && test -x /usr/sbin/havenfs && /usr/sbin/havenfs
    return
}

svr4net_on ()
{
    test -c /dev/tcp && (echo </dev/tcp) >/dev/null 2>&1
    return
}

configure () {
#  args:  $1 = interface name, $2 = address, $3 = ifconfig options filename
#	  $4 = "primary" or ""
    $ECHO "Configuring $1 as $2"
    case "$1" {
	ipg? | xpi? | imf?)
	    if /usr/etc/smtconfig $1 $2 $4 `cat $3 2> /dev/null` 2> /dev/null
	    then :
	    else
		$IFCONFIG $1 inet $2 $4 `cat $3 2> /dev/null` 2> /dev/null
	    fi
	    ;;
	fv? | gtr?)
	    /usr/etc/trconfig $1 -u > /dev/null 2>&1
	    $IFCONFIG $1 inet $2 $4 `cat $3 2> /dev/null` 2> /dev/null
	    ;;
	*)
	    $IFCONFIG $1 inet $2 $4 `cat $3 2> /dev/null` 2> /dev/null
	    ;;
    }
    if test $? -ne 0 ; then
	$LOGGER "Failed to configure $1 as $2.\n"
	sleep $MSGTIME
	return 1
    fi
    return 0
}


if test "`/sbin/nvram diskless 2> /dev/null`" -eq 1; then
    DLMNTOPTS='-b /,/usr,/sbin,/swap'
    RFLUSHFLAG=-fq
else
    RFLUSHFLAG=-Fq
fi


case "$1" in
'start')

    # Check the Internet address to decide how to configure things.

    HOSTNAME=`hostname`
    netstate="loopback"
    if test -x /usr/bsd/hostid; then
	if hostid -h $HOSTNAME; then
	    if test "`hostid`" = "0xc0000201"; then
		reason="${HOSTNAME}'s Internet address is the default.\n"
	    elif $IS_ON network; then
		netstate="ok"
	    fi
	else
	    hostid 0
	    reason="Cannot find $HOSTNAME in /etc/hosts.\n"
	fi
    elif $IS_ON network; then
	netstate="ok"	# assume it's ok
    fi

    if svr4net_on; then
	SHORTNAME=`hostname -s`
	echo $SHORTNAME $SHORTNAME > /etc/net/ticlts/hosts    2>/dev/null
	echo $SHORTNAME $SHORTNAME > /etc/net/ticots/hosts    2>/dev/null
	echo $SHORTNAME $SHORTNAME > /etc/net/ticotsord/hosts 2>/dev/null
    fi

    # The following tests determine the names and addresses of the primary
    # and gateway interfaces for typical configurtations, where
    #   Name    = interface name reported by "/usr/etc/netstat -i".
    #   Address = hostname in /etc/hosts or an IP address in dot notation.
    #
    # Edit /etc/config/netif.options to override values computed below.
    #
    # Note: If this host has more than 2 interfaces, you must edit
    # /etc/config/netif.options to set the ifXname and ifXaddr variables
    # as appropriate, and set if_num to the number of interfaces if
    # there are more than 9.

    # Suggested addresses for the primary and gateway interfaces.
    if1addr=$HOSTNAME
    if2addr=gate-$HOSTNAME
    if_num=9

    # If FDDI is present, make it the primary interface and
    # Ethernet the gateway interface.
    if $IFCONFIG ipg0 >/dev/null 2>&1; then
	if1name=ipg0
    elif $IFCONFIG xpi0 >/dev/null 2>&1; then
	if1name=xpi0
    fi

    if test "$if1name"; then
	if $IFCONFIG et0 >/dev/null 2>&1; then
	    # Challenge/Onyx & POWER Series systems
	    if2name=et0
	elif $IFCONFIG ec0 >/dev/null 2>&1; then
	    # Indigo & Personal Iris series
	    if2name=ec0
	elif $IFCONFIG fxp0 >/dev/null 2>&1; then	# Professional IRIS
	    if2name=fxp0				# (4D/50-4D/85)
	elif $IFCONFIG enp0 >/dev/null 2>&1; then	# ditto
	    if2name=enp0
	elif $IFCONFIG gtr0 >/dev/null 2>&1; then
	    # Indigo series Token Ring
	    if2name=gtr0
	    if2addr=tr-$HOSTNAME
	elif $IFCONFIG fv0 >/dev/null 2>&1; then
	    # POWER Series systems Token Ring
	    if2name=fv0
	    if2addr=tr-$HOSTNAME
	fi
    elif $IFCONFIG et0 >/dev/null 2>&1; then
	if1name=et0
	if $IFCONFIG et1 >/dev/null 2>&1; then
	    if2name=et1
	elif $IFCONFIG fxp0 >/dev/null 2>&1; then
	    if2name=fxp0
	elif $IFCONFIG enp0 >/dev/null 2>&1; then
	    if2name=enp0
	elif $IFCONFIG fv0 >/dev/null 2>&1; then
	    if2name=fv0
	    if2addr=tr-$HOSTNAME
	fi
    elif $IFCONFIG ec0 >/dev/null 2>&1; then
	if1name=ec0
	if $IFCONFIG ec1 >/dev/null 2>&1; then
	    if2name=ec1
	    if $IFCONFIG ec2 >/dev/null 2>&1; then
		if3name=ec2
	    fi
	elif $IFCONFIG ec2 >/dev/null 2>&1; then
	    if2name=ec2
	elif $IFCONFIG fxp0 >/dev/null 2>&1; then
	    if2name=fxp0
	elif $IFCONFIG enp0 >/dev/null 2>&1; then
	    if2name=enp0
	elif $IFCONFIG gtr0 >/dev/null 2>&1; then
	    if2name=gtr0
	    if2addr=tr-$HOSTNAME
	elif $IFCONFIG fv0 >/dev/null 2>&1; then
	    if2name=fv0
	    if2addr=tr-$HOSTNAME
	fi
    elif $IFCONFIG fxp0 >/dev/null 2>&1; then
	if1name=fxp0
	if $IFCONFIG fxp1 >/dev/null 2>&1; then
	    if2name=fxp1
	elif $IFCONFIG enp0 >/dev/null 2>&1; then
	    if2name=enp0
	elif $IFCONFIG fv0 >/dev/null 2>&1; then
	    if2name=fv0
	    if2addr=tr-$HOSTNAME
	fi
    elif $IFCONFIG enp0 >/dev/null 2>&1; then
	if1name=enp0
	if2name=enp1
    fi

    # Obtain site-dependent values for if1name,if1addr,...,if64name,if64addr.
    if test -s $CONFIG/netif.options; then
	. $CONFIG/netif.options
    fi

    # IP Packet Filtering daemon.
    #
    # It should be started before any gateway interface is configured "up"
    # in order to guarantee that all inbound packets are filtered.
    if $IS_ON ipfilterd && test -x /usr/etc/ipfilterd; then
	/sbin/killall ipfilterd
	/usr/etc/ipfilterd `cat $CONFIG/ipfilterd.options 2> /dev/null`
	$ECHO "Starting ipfilterd."
    fi

    # Flush all old routes iff not diskless
    $ROUTE $RFLUSHFLAG >/dev/null 2>&1

    # Configure the main network interface.
    if test "$netstate" = "ok"; then
	# update E-Plex 8-port Ethernet firmware.
	if test -x /usr/etc/epfirm; then
	    /usr/etc/epfirm $VERBOSE
	    if test $? -ne 0 ; then
		$LOGGER "Failed to install E-Plex firmware.\n"
		sleep $MSGTIME
	    fi
	fi
	if configure $if1name $if1addr $CONFIG/ifconfig-1.options primary;
	then :
	else
	    reason="Cannot access primary interface, $if1name.\n"
	    netstate="loopback"
	fi
    elif test "$netstate" != "loopback"; then
	netstate="loopback"
    fi


    if test $netstate = "loopback"; then
	$LOGGER "${reason}Using standalone network mode.\n"
	sleep $MSGTIME

	if test "$if1name" != ""; then
	    $IFCONFIG $if1name inet $if1addr 2>/dev/null
	    $IFCONFIG $if1name down          2>/dev/null
	fi
	$IFCONFIG lo0 $localhost
	$ROUTE -q delete net $if1addr $if1addr >/dev/null 2>&1
	$ROUTE -q add 224.0.0.0 $localhost 0   >/dev/null 2>&1
    else
	# Initialize other boards if this host is a gateway or multi-homed
	# (no harm if they are missing). Systems with more than 2 interfaces
	# must update /etc/config/netif.options (see comments in the file).

	num=2
	while test $num -le $if_num; do
	    eval _ifname='$'if${num}name _ifaddr='$'if${num}addr
	    if test -n "$_ifname"; then
		if $IFCONFIG $_ifname >/dev/null 2>&1; then
		    configure $_ifname $_ifaddr $CONFIG/ifconfig-$num.options
		fi
	    fi

	    num=`expr $num + 1`
	done


	# Initialize the HyperNET interface.

	if $IS_ON hypernet && $IFCONFIG hy0 >/dev/null 2>&1  &&
	   configure hy0 $HOSTNAME-hy $CONFIG/ifconfig-hy.options ; then
	    /usr/etc/hyroute hy0 -s /usr/etc/hyroute.conf
	fi

	# Initialize the HIPPI interface.
	if test -s /etc/init.d/network.hippi; then
		. /etc/init.d/network.hippi
	fi

	# Initialize the loop-back interface
	$IFCONFIG lo0 $localhost
    fi

    # Send traffic for this host through lo0 for better performance
    HOSTRESORDER=local $ROUTE -q add host $if1addr $localhost 0 >/dev/null 2>&1


    $ECHO "Network daemons:\c"

	if test -x /usr/etc/rtnetd; then
	    # Always start on multiprocessors for better throughput
	    if $IS_ON rtnetd || test `mpadmin -u | wc -l` -gt 1; then
		/usr/etc/rtnetd `cat $CONFIG/rtnetd.options 2> /dev/null`
							$ECHO " rtnetd\c"
	    fi
	fi

	/sbin/killall gated routed mrouted rpcbind portmap named

	if test $netstate = "ok" ; then

	    # Start either gated (the fancy routing daemon) or routed.
	    #
	    # Note: gated and mrouted use configuration files in /usr/etc.
	    # See gated(1M) and mrouted(1M) for details on their setup.

	    if $IS_ON gated && test -x /usr/etc/gated ; then

	        /usr/etc/gated `cat $CONFIG/gated.options 2> /dev/null` &
							$ECHO " gated\c"
	    elif $IS_ON routed && test -x /usr/etc/routed ; then

		# Useful option:
		#	-q = "quiet": don't act as router if > 1 interface.
		# See routed(1M) for other options.

		/usr/etc/routed `cat $CONFIG/routed.options 2> /dev/null` &
							$ECHO " routed\c"
	    fi

	    # Set the default route for all IP multicast packets to the
	    # primary interface.
	   HOSTRESORDER=local $ROUTE -q add 224.0.0.0 $if1addr 0 >/dev/null 2>&1

	    if $IS_ON mrouted && test -x /usr/etc/mrouted; then
		/usr/etc/mrouted `cat $CONFIG/mrouted.options 2> /dev/null` &
							$ECHO " mrouted\c"
	    fi
	fi

	# Start rpcbind(1M) if SVR4 networking has been installed.
	if test -x /usr/etc/rpcbind && svr4net_on; then
	    /usr/etc/rpcbind `cat $CONFIG/portmap.options 2> /dev/null` &
							$ECHO " rpcbind\c"
	elif test -x /usr/etc/portmap; then
	    /usr/etc/portmap `cat $CONFIG/portmap.options 2> /dev/null` &
							$ECHO " portmap\c"
	fi

	# Berkeley Internet Name Domain server:
	#
	#   It has to be started before NIS and NFS so they can use hostnames
	#   not in /etc/hosts.
	if $IS_ON named && test -x /usr/sbin/named; then
	    /usr/sbin/named `cat $CONFIG/named.options 2> /dev/null` < /dev/null
							$ECHO " named\c"
	fi


    $ECHO "."


    # Define the NIS domain name.
    if test -x $YPSETDOM; then
	# The ypdomain file is needed only if NIS domain != Internet domain.
	YPDOMAIN=`cat $YPDOMFILE 2> /dev/null`

	if test ! "$YPDOMAIN" ; then
	    # Extract the domain from the hostname.
	    YPDOMAIN=`echo $HOSTNAME | sed -e 's/[^.]*\.\(.*\)/\1/'`
	    if test "$YPDOMAIN" = "$HOSTNAME"; then
		# Hostname doesn't contain domain.
		YPDOMAIN=""
	    fi
	fi

	# Set the domain even if "yp" is not "on" so ypbind can be
	# started by hand later.
	if test "$YPDOMAIN"; then
	    $YPSETDOM $YPDOMAIN
	fi
    fi

    # Fire up NIS daemons.

    if test $netstate = "ok" && $IS_ON yp ; then
	if test ! "$YPDOMAIN" ; then
	    $LOGGER "Cannot start NIS -- domain name not defined.\nEdit $YPDOMFILE to contain your domain name and reboot.\n"
	    sleep $MSGTIME
	else
	    YPDBDIR=/var/yp/$YPDOMAIN

	    $YPSETDOM  $YPDOMAIN
	    /sbin/killall ypbind ypserv rpc.passwd

	    $ECHO "NIS domain: $YPDOMAIN"
	    $ECHO "NIS daemons:\c"

		#   NIS type:		Must run:
		#   master server	ypserv, rpc.passwd, ypbind
		#   slave server	ypserv, ypbind
		#   client		ypbind

		# Make this host a NIS server.
		if $IS_ON ypserv && test -x $NFS/ypserv; then
		    if test -d $YPDBDIR ; then

			# Useful option:
			#   -i = get inter-domain host info from named

			$NFS/ypserv `cat $CONFIG/ypserv.options 2> /dev/null` &
							$ECHO " ypserv\c"
		    else
			$LOGGER "ypserv not started -- $YPDBDIR database directory missing.\n"
			sleep $MSGTIME
		    fi
		fi


		# Make this host the NIS master server for the passwd file.
		if $IS_ON ypmaster && test -x $NFS/rpc.passwd; then

		    # A reasonable alternate password file is '/etc/passwd.yp'
		    #	This allows the valid accounts on the NIS master
		    #	to not be all valid accounts in the network.
		    PASSWD=`cat $CONFIG/rpc.passwd.options 2> /dev/null`

		    $NFS/rpc.passwd ${PASSWD:=/etc/passwd} -m passwd &
							$ECHO " rpc.passwd\c"
		fi

		# ypbind allows NIS servers and clients to use NIS services.
		if test -x $NFS/ypbind; then
		    $NFS/ypbind `cat $CONFIG/ypbind.options 2> /dev/null` &
							$ECHO " ypbind\c"
		    # wait till ypbind running or time out
		    reps=5
		    y_err="ypwhich: $HOSTNAME is not running ypbind"
		    while test "$reps" -gt 0; do
			yres=`ypwhich 2>/dev/null`
			if test "$yres" = "$y_err" >/dev/null ; then
			    $ECHO ".\c"
			else
			    break
			fi
			reps=`expr $reps - 1`
			sleep 1
		    done
		fi

	    $ECHO "."
	fi
    fi

    #
    # Fire up AFS if configured - this needs to occur after networking
    # is enabled but before nfsd's are run
    #
    if test -x /etc/init.d/afs ; then
        /etc/init.d/afs netstart
    fi

    # Fire up NFS daemons if the kernel supports NFS and the daemons are
    # present and executable.  Also mount the NFS filesystems in /etc/fstab.

    if test "$netstate" = "ok" && nfs_on ; then

	# Clear this host from the client list (/etc/rmtab) of all
	# servers on the network.  Remove any stale exports from
	# the current exports list (/etc/xtab).

	2>&1 umount -at nfs ${DLMNTOPTS} > /dev/null
	2>&1 $NFS/exportfs -au > /dev/null
	$NFS/exportfs -a $VERBOSE

	$ECHO "NFS daemons:\c"

	    /sbin/killall nfsd biod

	    # NFS server daemons
	    if test -x $NFS/nfsd; then
		NNFSD=`cat $CONFIG/nfsd.options 2> /dev/null`
		$NFS/nfsd ${NNFSD:=4};			$ECHO " nfsd\c"
	    fi

	    # NFS client bio daemons
	    if test -x $NFS/biod; then
		NBIOD=`cat $CONFIG/biod.options 2> /dev/null`
		$NFS/biod ${NBIOD:=4};			$ECHO " biod\c"
	    fi

	$ECHO "."

	/sbin/mount $VERBOSE -at nfs ${DLMNTOPTS}

	if $IS_ON automount || $IS_ON lockd || $IS_ON pcnfsd ; then
	    $ECHO "Other NFS daemons:\c"

	    # Start the NFS automounter daemon
	    if $IS_ON automount && test -x $NFS/automount ; then
		/sbin/killall -k 30 -TERM automount
		$NFS/automount \
		    `cat $CONFIG/automount.options 2> /dev/null` >/dev/null 2>&1
							$ECHO " automount\c"
	    fi

	    # Start the NFS lock and status daemons
	    if $IS_ON lockd ; then
		if test -x $NFS/rpc.statd ; then
		    /sbin/killall rpc.statd
		    $NFS/rpc.statd `cat $CONFIG/statd.options 2> /dev/null`
							$ECHO " statd\c"
		fi
		if test -x $NFS/rpc.lockd ; then
		    /sbin/killall rpc.lockd
		    $NFS/rpc.lockd `cat $CONFIG/lockd.options 2> /dev/null` &
							$ECHO " lockd\c"
		fi
	    fi

	    # PC-NFS server daemon
	    if $IS_ON pcnfsd && test -x $NFS/pcnfsd ; then
		$NFS/pcnfsd & $ECHO " pcnfsd\c"
	    fi

	    $ECHO "."
	fi
    fi


    # Daemons started below may reside on NFS filesystems.

    $ECHO "Internet daemons:\c"

	/sbin/killall inetd timed timeslave rarpd rwhod snmpd

	# Internet super-server:
	#
	#  Invokes servers in /usr/etc/inetd.conf. Use the inetd.options file
	#  to specify a different configuration file.

	if test -x /usr/etc/inetd; then
	    /usr/etc/inetd `cat $CONFIG/inetd.options 2> /dev/null` < /dev/null
						$ECHO " inetd\c"
	fi


	# SVR4 service access controller
	if test -x /usr/lib/saf/sac && svr4net_on; then
	    rm -f /etc/saf/_sacpipe /etc/saf/tcp/_pmpipe 
	    /usr/lib/saf/sac -t 30  < /dev/null &
						$ECHO " sac\c"
	fi

	# Time synchronization servers:
	#  timed keeps time consistent among machines on a local network.
	#  timeslave tracks changes made by a master time keeper.
	#
	#  Timed can be given options in $CONFIG/timed.options, detailed
	#  in the timed(1M) man page.
	#
	#  Timeslave requires the name of host to follow (-H hostname)
	#  or the name of clock device that listens to WWV (-C /dev/ttyXX).
	#  Other options are listed in the man page.

	if $IS_ON timed && test $netstate = "ok" -a -x /usr/etc/timed ; then
	    /usr/etc/timed -M `cat $CONFIG/timed.options 2> /dev/null` &
						$ECHO " timed\c"
	fi
	if $IS_ON timeslave && test -x /usr/etc/timeslave ; then
	    if test -s $CONFIG/timeslave.options ; then
		/usr/etc/timeslave `cat $CONFIG/timeslave.options` &
						$ECHO " timeslave\c"
	    else
		$LOGGER "timeslave not started -- options missing.\nAdd them to %s and reboot.\n" "$CONFIG/timeslave.options"
		sleep $MSGTIME
	    fi
	fi


	# RARPD: Reverse ARP daemon.
	#
	#  RARP is used by Sun diskless clients to discover their Internet
	#  addresses, given their Ethernet addresses.

	if $IS_ON rarpd && test $netstate = "ok" -a -x /usr/etc/rarpd ; then
	    /usr/etc/rarpd `cat $CONFIG/rarpd.options 2> /dev/null` &
						$ECHO " rarpd\c"
	fi


	# Rwhod: 4.3BSD's system status daemon.
	#
	#  Important: if there are lots of hosts on the network,
	#  DO NOT run rwhod because it can saturate the network.

	if $IS_ON rwhod && test $netstate = "ok" -a -x /usr/etc/rwhod; then
	    if test ! -d /var/spool/rwho; then
		mkdir /var/spool/rwho
	    fi
	    /usr/etc/rwhod `cat $CONFIG/rwhod.options 2> /dev/null`
						$ECHO " rwhod\c"
	fi


	# snmpd: Simple Network Management Protocol daemon.
	#
	# SNMP (RFC 1157) is used to query MIB variables (RFC 1158)
	# from a network entity.

	if $IS_ON snmpd && test $netstate = "ok" -a -x /usr/etc/snmpd; then
	    /usr/etc/snmpd `cat $CONFIG/snmpd.options 2> /dev/null`
						$ECHO " snmpd\c"
	fi

    $ECHO "."

    # DLPI daemon must be started before 4DDN.
    if $IS_ON snetd && test -x /usr/etc/snetd ; then
	/usr/etc/snetd
    fi

    if $IS_ON 4DDN && test $netstate = "ok" -a -x /var/opt/dn/dnstart.sh; then
	/sbin/killall -TERM dnserver
	/var/opt/dn/dnstart.sh $VERBOSE
    fi

    # Token ring configuration
    if test -x /usr/etc/tr/trconfig.sh; then
	/usr/etc/tr/trconfig.sh
    fi
    ;;


'stop')

    #  Servers that might start shells.
    USERS='rlogind rexecd rshd ftpd telnetd sethostd dnserver comlink latd'
    #  The following servers should be killed immediately.
    EDAEMONS='inetd bootp tftpd timed timeslave rarpd rwhod talkd fingerd
		automount rpc.mountd rpc.lockd rpc.statd rpc.bootparamd
		rpc.rexd rpc.rstatd rpc.rusersd rpc.rwalld rpc.ypupdated
		fal smtd snmpd sac listen osid'
    #  Remote daemons
    RDAEMONS='ypserv ypbind rpc.passwd nfsd biod pcnfsd rpc.rquotad
		named gated routed mrouted'
    #  These daemons should be kept alive until the last minute.
    LDAEMONS='portmap rpcbind ppp slip ipfilterd snetd'

    #  Kill (probable) shell process groups first
    /sbin/killall -k 1 -g 1 $USERS
    /sbin/killall -k 1 -TERM $EDAEMONS $USERS

    /sbin/umount $VERBOSE -kt nfs ${DLMNTOPTS}
    /sbin/killall -k 1 -TERM $RDAEMONS

    #  Unexport any exported NFS filesystems (assumes netstate = ok)
    #	Do this after killing the NFS demons so that clients do not
    #	suffer errors on their read(2) requests, if they have hard-mounted
    #	things.  /usr may not be mounted, so you must check to see
    #	that exportfs is available.
    if nfs_on && test -x $NFS/exportfs; then
	$NFS/exportfs -au $VERBOSE
    fi

    #  Blow away any background mounts and the broadcast umount since
    #	the network will be shut down soon.
    /sbin/killall mount umount $USERS $EDAEMONS $RDAEMONS $LDAEMONS rtnetd

    #  Shutdown FDDI to turn off the optical bypasses and cleanly take
    #  the system out of the ring.
    #  Shutdown TokenRing for MAU to take the system out of the ring cleanly.
    for num in 0 1 2 3 ; do
	$IFCONFIG ipg$num down 2> /dev/null
	$IFCONFIG xpi$num down 2> /dev/null
	$IFCONFIG fv$num down 2> /dev/null
	$IFCONFIG gtr$num down 2> /dev/null
    done

    # Shutdown HIPPI interface
    if test -s /etc/init.d/network.hippi; then
	. /etc/init.d/network.hippi
    fi

    #  Shutdown ethernet (Indigo family (IP12/IP20/IP22))
    $IFCONFIG ec1 down 2> /dev/null
    $IFCONFIG ec2 down 2> /dev/null

    ;;


*)
    echo "usage: $0 {start|stop}"
    ;;
esac

# DECnet is a trademark of Digital Equipment Corp.
# NFS is a trademark of Sun Microsystems, Inc.
