xref: /dragonfly/etc/rc.d/nfsclient (revision 38a690d7)
1#!/bin/sh
2#
3# $FreeBSD: src/etc/rc.d/nfsclient,v 1.3 2002/10/12 10:31:31 schweikh Exp $
4# $DragonFly: src/etc/rc.d/nfsclient,v 1.1 2003/07/24 06:35:37 dillon Exp $
5#
6
7# PROVIDE: nfsclient
8# REQUIRE: NETWORKING mountcritremote rpcbind
9# KEYWORD: DragonFly FreeBSD shutdown
10
11. /etc/rc.subr
12
13name="nfsclient"
14rcvar="nfs_client_enable"
15start_cmd="nfsclient_start"
16start_precmd="nfsclient_precmd"
17stop_cmd="unmount_all"
18
19# Load nfs module if it was not compiled into the kernel
20nfsclient_precmd()
21{
22	if ! sysctl vfs.nfs >/dev/null 2>&1; then
23		if ! kldload nfsclient; then
24			warn 'Could not load nfs client module'
25			return 1
26		fi
27	fi
28	return 0
29}
30
31nfsclient_start()
32{
33	#
34	# Run nfsiod and set some nfs client related sysctls
35	#
36	if [ -n "${nfs_client_flags}" ]; then
37		echo -n ' nfsiod'
38		nfsiod ${nfs_client_flags}
39	fi
40
41	if [ -n "${nfs_access_cache}" ]; then
42		echo "NFS access cache time=${nfs_access_cache}"
43		sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null
44	fi
45	if [ -n "${nfs_bufpackets}" ]; then
46		 sysctl vfs.nfs.bufpackets=${nfs_bufpackets} > /dev/null
47	fi
48
49	unmount_all
50}
51
52unmount_all()
53{
54	# If /var/db/mounttab exists, some nfs-server has not been
55	# successfully notified about a previous client shutdown.
56	# If there is no /var/db/mounttab, we do nothing.
57	if [ -f /var/db/mounttab ]; then
58		rpc.umntall -k
59	fi
60}
61load_rc_config $name
62run_rc_command "$1"
63