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