nfsd revision 221046
178344Sobrien#!/bin/sh
278344Sobrien#
398184Sgordon# $FreeBSD: head/etc/rc.d/nfsd 221046 2011-04-26 00:22:17Z rmacklem $
478344Sobrien#
578344Sobrien
678344Sobrien# PROVIDE: nfsd
7193354Srmacklem# REQUIRE: mountd hostname gssd nfsuserd
8180564Sdougb# KEYWORD: nojail shutdown
978344Sobrien
1078344Sobrien. /etc/rc.subr
1178344Sobrien
1278344Sobrienname="nfsd"
1398184Sgordonrcvar=`set_rcvar nfs_server`
1499550Sgordoncommand="/usr/sbin/${name}"
1578344Sobrien
16109770Smtmload_rc_config $name
17124622Smtmstart_precmd="nfsd_precmd"
18124622Smtmsig_stop="USR1"
1998184Sgordon
2098184Sgordonnfsd_precmd()
2198184Sgordon{
22221046Srmacklem	if checkyesno oldnfs_server_enable; then
23221046Srmacklem		rc_flags="-o ${nfs_server_flags}"
24193354Srmacklem
25193354Srmacklem		if ! sysctl vfs.nfsrv >/dev/null 2>&1; then
26193354Srmacklem			force_depend nfsserver || return 1
27193354Srmacklem		fi
28193354Srmacklem
29193354Srmacklem		if checkyesno nfs_reserved_port_only; then
30193354Srmacklem			echo 'NFS on reserved port only=YES'
31193354Srmacklem			sysctl vfs.nfsrv.nfs_privport=1 > /dev/null
32193354Srmacklem		fi
33221046Srmacklem	else
34221046Srmacklem		rc_flags="${nfs_server_flags}"
35221046Srmacklem
36221046Srmacklem		# Load the modules now, so that the vfs.newnfs sysctl
37221046Srmacklem		# oids are available.
38221046Srmacklem		load_kld nfsd
39221046Srmacklem
40221046Srmacklem		if checkyesno nfs_reserved_port_only; then
41221046Srmacklem			echo 'NFS on reserved port only=YES'
42221046Srmacklem			sysctl vfs.newnfs.nfs_privport=1 > /dev/null
43221046Srmacklem		fi
44221046Srmacklem
45221046Srmacklem		if checkyesno nfsv4_server_enable; then
46221046Srmacklem			if ! checkyesno nfsuserd_enable  && \
47221046Srmacklem			    ! /etc/rc.d/nfsuserd forcestatus 1>/dev/null 2>&1
48221046Srmacklem			then
49221046Srmacklem				if ! force_depend nfsuserd; then
50221046Srmacklem					err 1 "Cannot run nfsuserd"
51221046Srmacklem				fi
52221046Srmacklem			fi
53221046Srmacklem		else
54221046Srmacklem			echo 'NFSv4 is disabled'
55221046Srmacklem			sysctl vfs.newnfs.server_max_nfsvers=3 > /dev/null
56221046Srmacklem		fi
5798184Sgordon	fi
5898184Sgordon
59101851Sgordon	if ! checkyesno rpcbind_enable  && \
60101851Sgordon	    ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
61101851Sgordon	then
62101851Sgordon		force_depend rpcbind || return 1
63101851Sgordon	fi
64101851Sgordon
65101851Sgordon	if ! checkyesno mountd_enable  && \
66101851Sgordon	    ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1
67101851Sgordon	then
68101851Sgordon		force_depend mountd || return 1
69101851Sgordon	fi
7098184Sgordon	return 0
7198184Sgordon}
7298184Sgordon
7378344Sobrienrun_rc_command "$1"
74