xref: /freebsd/libexec/rc/rc.d/nfsd (revision 6844eecfed0259958093d66e18ec06c06d13ca62)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: nfsd
7# REQUIRE: mountcritremote mountd hostname gssd nfsuserd
8# KEYWORD: nojail shutdown
9
10. /etc/rc.subr
11
12name="nfsd"
13desc="Remote NFS server"
14rcvar="nfs_server_enable"
15command="/usr/sbin/${name}"
16nfs_server_vhost=""
17
18load_rc_config $name
19start_precmd="nfsd_precmd"
20sig_stop="USR1"
21
22nfsd_precmd()
23{
24	local	_vhost
25	rc_flags="${nfs_server_flags}"
26
27	# Load the modules now, so that the vfs.nfsd sysctl
28	# oids are available.
29	load_kld nfsd || return 1
30
31	if checkyesno nfs_reserved_port_only; then
32		echo 'NFS on reserved port only=YES'
33		sysctl vfs.nfsd.nfs_privport=1 > /dev/null
34	else
35		sysctl vfs.nfsd.nfs_privport=0 > /dev/null
36	fi
37
38	if checkyesno nfs_server_managegids; then
39		force_depend nfsuserd || err 1 "Cannot run nfsuserd"
40	fi
41
42	if checkyesno nfsv4_server_enable; then
43		sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
44	elif ! checkyesno nfsv4_server_only; then
45		echo 'NFSv4 is disabled'
46		sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
47	fi
48
49	if ! checkyesno nfsv4_server_only; then
50		force_depend rpcbind || return 1
51	fi
52
53	force_depend mountd || return 1
54	if [ -n "${nfs_server_vhost}" ]; then
55		command_args="-V \"${nfs_server_vhost}\""
56	fi
57}
58
59run_rc_command "$1"
60