#!/bin/sh

. /etc/rc.common

CheckForNetwork 

if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi

ConsoleMessage "Mounting remote file systems"

##
# Set up NFS client.
##

##
# nsfiod is the NFS asynchronous block I/O daemon, which implements
# NFS read-ahead and write-behind caching on NFS clients.
##

nfsiod -n 4 

##
# Set up NFS server.
##

# 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).

# Clear the table of exported filesystems.
rm -f /var/db/mountdtab

exports=$(niutil -list . /exports 2> /dev/null | wc -w)

if [ "${exports}" -gt 0 ]; then
    ConsoleMessage "Starting Network File System server"
    mountd

	# If the NetInfo config/nfsd directory contains startup args for nfsd, use those.
	arguments=`niutil -readprop . /config/nfsd arguments`
	nfsd ${arguments:-"-t -u -n 6"}
fi

##
# Start the automounter
##

if [ "${AUTOMOUNT:=-YES-}" = "-YES-" ]; then
    automount -m /Network/Servers -fstab -m /automount -static
fi
