]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/nfsd
stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / nfsd
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
12 name="nfsd"
13 desc="Remote NFS server"
14 rcvar="nfs_server_enable"
15 command="/usr/sbin/${name}"
16 nfs_server_vhost=""
17
18 load_rc_config $name
19 start_precmd="nfsd_precmd"
20 sig_stop="USR1"
21
22 nfsd_precmd()
23 {
24         local   _vhost
25         rc_flags="${nfs_server_flags}"
26
27         # Load the modules now, so that the vfs.nfsd sysctl
28         # oids are available.
29         load_kld nfsd
30
31         if checkyesno nfs_reserved_port_only; then
32                 echo 'NFS on reserved port only=YES'
33                 sysctl vfs.nfsd.nfs_privport=1 > /dev/null
34         else
35                 sysctl vfs.nfsd.nfs_privport=0 > /dev/null
36         fi
37
38         if checkyesno nfs_server_managegids; then
39                 force_depend nfsuserd || err 1 "Cannot run nfsuserd"
40         fi
41
42         if checkyesno nfsv4_server_enable; then
43                 sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
44         else
45                 echo 'NFSv4 is disabled'
46                 sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
47         fi
48
49         force_depend rpcbind || return 1
50         force_depend mountd || return 1
51         if [ -n "${nfs_server_vhost}" ]; then
52                 command_args="-V \"${nfs_server_vhost}\""
53         fi
54 }
55
56 run_rc_command "$1"