3 # Startup script for nfs-utils
5 # The nfsd kernel module must exist along with its dependencies
6 modprobe -n nfsd || exit 0
8 # The environment variable NFS_SERVERS may be set in /etc/default/nfsd
9 # Other control variables may be overridden here too
10 test -r /etc/default/nfsd && . /etc/default/nfsd
12 # Location of exectuables:
13 test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/mountd
14 test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/nfsd
16 # The user mode program must also exist (it just starts the kernel
17 # threads using the kernel module code).
18 test -x "$NFS_MOUNTD" || exit 0
19 test -x "$NFS_NFSD" || exit 0
21 # Default is 8 threads, value is settable between 1 and the truely
23 test "$NFS_SERVERS" -gt 0 && "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8
25 # The default state directory is /var/lib/nfs
26 test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs
28 #----------------------------------------------------------------------
29 # Startup and shutdown functions.
30 # Actual startup/shutdown is at the end of this file.
33 echo -n 'creating NFS state directory: '
34 mkdir -p "$NFS_STATEDIR"
43 for file in xtab etab smtab rmtab
55 echo -n 'starting mountd: '
56 start-stop-daemon --start --exec "$NFS_MOUNTD" -- "$@"
60 echo -n 'stopping mountd: '
61 start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD"
67 echo -n "starting $1 nfsd kernel threads: "
68 start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
72 for delay in 0 1 2 3 4 5 6 7 8 9
74 if pidof nfsd >/dev/null
85 # WARNING: this kills any process with the executable
87 echo -n 'stopping nfsd: '
88 start-stop-daemon --stop --quiet --signal 1 --name nfsd
91 echo ' using signal 9: '
92 start-stop-daemon --stop --quiet --signal 9 --name nfsd
97 # This will remove, recursively, dependencies
98 echo -n 'removing nfsd kernel module: '
109 #----------------------------------------------------------------------
114 # reload: reloads the exports file
115 # restart: stops and starts mountd
116 #FIXME: need to create the /var/lib/nfs/... directories
118 start) create_directories
119 start_nfsd "$NFS_SERVERS"
121 test -r /etc/exports && exportfs -a;;
125 reload) test -r /etc/exports && exportfs -r;;
128 # restart does not restart the kernel threads,
129 # only the user mode processes
131 test -r /etc/exports && exportfs -a;;