xref: /freebsd/libexec/rc/rc.d/nfsd (revision e9b1dc32c9bd2ebae5f9e140bfa0e0321bc366b5)
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}"
16
17load_rc_config $name
18start_precmd="nfsd_precmd"
19sig_stop="USR1"
20
21nfsd_precmd()
22{
23	rc_flags="${nfs_server_flags}"
24
25	# Load the modules now, so that the vfs.nfsd sysctl
26	# oids are available.
27	load_kld nfsd
28
29	if checkyesno nfs_reserved_port_only; then
30		echo 'NFS on reserved port only=YES'
31		sysctl vfs.nfsd.nfs_privport=1 > /dev/null
32	else
33		sysctl vfs.nfsd.nfs_privport=0 > /dev/null
34	fi
35
36	if checkyesno nfs_server_managegids; then
37		force_depend nfsuserd || err 1 "Cannot run nfsuserd"
38	fi
39
40	if checkyesno nfsv4_server_enable; then
41		sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
42	else
43		echo 'NFSv4 is disabled'
44		sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
45	fi
46
47	force_depend rpcbind || return 1
48	force_depend mountd || return 1
49}
50
51run_rc_command "$1"
52