]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/etc/rc.d/nfsclient
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / etc / rc.d / nfsclient
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: nfsclient
7 # REQUIRE: NETWORKING mountcritremote rpcbind
8 # KEYWORD: nojail shutdown
9
10 . /etc/rc.subr
11
12 name="nfsclient"
13 rcvar="nfs_client_enable"
14 start_cmd="nfsclient_start"
15 start_precmd="nfsclient_precmd"
16 stop_cmd="unmount_all"
17
18 # Load nfs module if it was not compiled into the kernel
19 nfsclient_precmd()
20 {
21         if ! sysctl vfs.nfs >/dev/null 2>&1; then
22                 if ! kldload nfsclient; then
23                         warn 'Could not load nfs client module'
24                         return 1
25                 fi
26         fi
27         return 0
28 }
29
30 nfsclient_start()
31 {
32         #
33         # Set some nfs client related sysctls
34         #
35
36         if [ -n "${nfs_access_cache}" ]; then
37                 echo "NFS access cache time=${nfs_access_cache}"
38                 sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null
39         fi
40         if [ -n "${nfs_bufpackets}" ]; then
41                  sysctl vfs.nfs.bufpackets=${nfs_bufpackets} > /dev/null
42         fi
43
44         unmount_all
45 }
46
47 unmount_all()
48 {
49         # If /var/db/mounttab exists, some nfs-server has not been
50         # successfully notified about a previous client shutdown.
51         # If there is no /var/db/mounttab, we do nothing.
52         if [ -f /var/db/mounttab ]; then
53                 rpc.umntall -k
54         fi
55 }
56 load_rc_config $name
57 run_rc_command "$1"