xref: /freebsd/libexec/rc/rc.d/mountd (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: mountd
7# REQUIRE: NETWORKING rpcbind quota
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	fi
38
39	# mountd flags will differ depending on rc.conf settings
40	#
41	if checkyesno nfs_server_enable || checkyesno nfsv4_server_only; then
42		if checkyesno weak_mountd_authentication; then
43			if checkyesno nfsv4_server_only; then
44				echo -n 'weak_mountd_authentication '
45				echo -n 'incompatible with nfsv4_server_only, '
46				echo 'ignored'
47			else
48				rc_flags="${rc_flags} -n"
49			fi
50		fi
51	else
52		if checkyesno mountd_enable; then
53			checkyesno weak_mountd_authentication && rc_flags="-n"
54		fi
55	fi
56
57	if checkyesno zfs_enable; then
58		rc_flags="${rc_flags} /etc/exports /etc/zfs/exports"
59	fi
60
61	rm -f /var/db/mountdtab
62	( umask 022 ; > /var/db/mountdtab ) ||
63	    err 1 'Cannot create /var/db/mountdtab'
64}
65
66load_rc_config $name
67run_rc_command "$1"
68