xref: /freebsd/libexec/rc/rc.d/mountd (revision 064f00ec274fbfdcab19ed8150afb187468a0c4f)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: mountd
7# REQUIRE: NETWORKING rpcbind quota mountlate
8# KEYWORD: nojail shutdown
9
10. /etc/rc.subr
11
12name="mountd"
13desc="Service remote NFS mount requests"
14rcvar="mountd_enable"
15command="/usr/sbin/${name}"
16pidfile="/var/run/${name}.pid"
17required_files="/etc/exports"
18start_precmd="mountd_precmd"
19extra_commands="reload"
20
21mountd_precmd()
22{
23
24	# Load the modules now, so that the vfs.nfsd sysctl
25	# oids are available.
26	load_kld nfsd || return 1
27
28	# Do not force rpcbind to be running for an NFSv4 only server.
29	#
30	if checkyesno nfsv4_server_only; then
31		echo 'NFSv4 only server'
32		sysctl vfs.nfsd.server_min_nfsvers=4 > /dev/null
33		sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
34		rc_flags="${rc_flags} -R"
35	else
36		force_depend rpcbind || return 1
37		if ! checkyesno nfsv4_server_enable; then
38			sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
39		fi
40	fi
41
42	# mountd flags will differ depending on rc.conf settings
43	#
44	if checkyesno nfs_server_enable || checkyesno nfsv4_server_only; then
45		if checkyesno weak_mountd_authentication; then
46			if checkyesno nfsv4_server_only; then
47				echo -n 'weak_mountd_authentication '
48				echo -n 'incompatible with nfsv4_server_only, '
49				echo 'ignored'
50			else
51				rc_flags="${rc_flags} -n"
52			fi
53		fi
54	else
55		if checkyesno mountd_enable; then
56			checkyesno weak_mountd_authentication && rc_flags="-n"
57		fi
58	fi
59
60	if checkyesno zfs_enable; then
61		rc_flags="${rc_flags} /etc/exports /etc/zfs/exports"
62	fi
63
64	rm -f /var/db/mountdtab
65	( umask 022 ; > /var/db/mountdtab ) ||
66	    err 1 'Cannot create /var/db/mountdtab'
67}
68
69load_rc_config $name
70run_rc_command "$1"
71