4 # This shell script takes care of starting and stopping
5 # the kernel-mode NFS server.
8 # description: NFS is a popular protocol for file sharing across TCP/IP \
9 # networks. This service provides NFS server functionality, \
10 # which is configured via the /etc/exports file.
14 [ -x $PREFIX/sbin/rpc.nfsd ] || exit 0
15 [ -x $PREFIX/sbin/rpc.mountd ] || exit 0
16 [ -x $PREFIX/sbin/exportfs ] || exit 0
19 DESC="NFS kernel daemon"
21 RPCNFSDCOUNT=8 # Number of servers to be started up by default
24 # Make sure that daemon cwds are in root fs.
27 # See how we were called.
30 if grep -q '^/' /etc/exports; then
31 printf "Exporting directories for $DESC..."
32 $PREFIX/sbin/exportfs -r
35 printf "Starting $DESC:"
37 start-stop-daemon --start --quiet \
38 --exec $PREFIX/sbin/rpc.nfsd -- $RPCNFSDCOUNT
40 $PREFIX/bin/rpcinfo -u localhost nfs 3 > /dev/null 2>&1 ||
41 RPCMOUNTDOPTS="$RPCMOUNDOPTS --no-nfs-version 3"
42 start-stop-daemon --start --quiet \
43 --exec $PREFIX/sbin/rpc.mountd -- $RPCMOUNTDOPTS
46 echo "Not starting $DESC: No exports."
51 printf "Stopping $DESC: mountd"
52 start-stop-daemon --stop --oknodo --quiet \
53 --exec $PREFIX/sbin/rpc.mountd
55 start-stop-daemon --stop --oknodo --quiet \
56 --name nfsd --user root --signal 2
59 printf "Unexporting directories for $DESC..."
60 $PREFIX/sbin/exportfs -au
64 reload | force-reload)
65 printf "Re-exporting directories for $DESC..."
66 $PREFIX/sbin/exportfs -r
77 echo "Usage: nfs-kernel-server {start|stop|reload|force-reload|restart}"