xref: /freebsd/libexec/rc/rc.d/nfsd (revision a50d73d5782a351ad83e8d1f84d11720a12e70d3)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: nfsd
7# REQUIRE: mountcritremote mountd hostname gssd nfsuserd
8# KEYWORD: nojailvnet 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 [ -n "${nfs_server_maxio}" ] && ! check_jail jailed; then
32		if ! sysctl vfs.nfsd.srvmaxio=${nfs_server_maxio} >/dev/null; then
33			warn "Failed to set server max I/O"
34		fi
35	fi
36
37	if checkyesno nfs_reserved_port_only; then
38		echo 'NFS on reserved port only=YES'
39		sysctl vfs.nfsd.nfs_privport=1 > /dev/null
40	else
41		sysctl vfs.nfsd.nfs_privport=0 > /dev/null
42	fi
43
44	if checkyesno nfs_server_managegids; then
45		force_depend nfsuserd || err 1 "Cannot run nfsuserd"
46	fi
47
48	if checkyesno nfsv4_server_enable; then
49		sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
50	elif ! checkyesno nfsv4_server_only; then
51		echo 'NFSv4 is disabled'
52		sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
53	fi
54
55	if ! checkyesno nfsv4_server_only; then
56		force_depend rpcbind || return 1
57	fi
58
59	force_depend mountd || return 1
60	if [ -n "${nfs_server_vhost}" ]; then
61		command_args="-V \"${nfs_server_vhost}\""
62	fi
63}
64
65run_rc_command "$1"
66