Fix path for nfs mounts, and correct sysctl
[dragonfly.git] / etc / rc.d / nfsd
1 #!/bin/sh
2 #
3 # $NetBSD: nfsd,v 1.4 2001/06/16 06:13:10 lukem Exp $
4 # $FreeBSD: src/etc/rc.d/nfsd,v 1.9 2003/01/24 00:37:52 mtm Exp $
5 # $DragonFly: src/etc/rc.d/nfsd,v 1.2 2003/08/10 10:11:13 rob Exp $
6 #
7
8 # PROVIDE: nfsd
9 # REQUIRE: mountd
10 # KEYWORD: DragonFly FreeBSD NetBSD
11
12 . /etc/rc.subr
13
14 name="nfsd"
15 rcvar=`set_rcvar nfs_server`
16 command="/sbin/${name}"
17
18 load_rc_config $name
19 case ${OSTYPE} in
20 DragonFly)
21         command_args="${nfs_server_flags}"
22         start_precmd="nfsd_precmd"
23         sig_stop="USR1"
24         ;;
25
26 FreeBSD)
27         command_args="${nfs_server_flags}"
28         start_precmd="nfsd_precmd"
29         sig_stop="USR1"
30         ;;
31 NetBSD)
32         required_vars="mountd rpcbind"
33         start_precmd=
34         ;;
35 esac
36
37 nfsd_precmd()
38 {
39         if ! sysctl vfs.nfs >/dev/null 2>&1; then
40                 force_depend nfsserver || return 1
41         fi
42
43         if ! checkyesno rpcbind_enable  && \
44             ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
45         then
46                 force_depend rpcbind || return 1
47         fi
48
49         if ! checkyesno mountd_enable  && \
50             ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1
51         then
52                 force_depend mountd || return 1
53         fi
54
55         if checkyesno nfs_reserved_port_only; then
56                 echo 'NFS on reserved port only=YES'
57                 sysctl vfs.nfs.nfs_privport=1 > /dev/null
58         fi
59         return 0
60 }
61
62 run_rc_command "$1"