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