]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/debian/nfs-kernel-server
1/ be less trusting of information in /var/lib/nfs/xtab. Add things to
[nfs-utils.git] / etc / debian / nfs-kernel-server
1 #!/bin/sh
2 #
3 # nfs-kernel-server
4 #               This shell script takes care of starting and stopping
5 #               the kernel-mode NFS server.
6 #
7 # chkconfig: 345 60 20
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.
11 #
12
13 PREFIX=/usr
14 [ -x $PREFIX/sbin/rpc.nfsd ] || exit 0
15 [ -x $PREFIX/sbin/rpc.mountd ] || exit 0
16 [ -x $PREFIX/sbin/exportfs ] || exit 0
17
18 # What is this?
19 DESC="NFS kernel daemon"
20
21 RPCNFSDCOUNT=8  # Number of servers to be started up by default
22 RPCMOUNTDOPTS=
23
24 # Make sure that daemon cwds are in root fs.
25 cd /
26
27 # See how we were called.
28 case "$1" in
29   start)
30         if grep -q '^/' /etc/exports; then
31                 printf "Exporting directories for $DESC..."
32                 $PREFIX/sbin/exportfs -r
33                 echo "done."
34
35                 printf "Starting $DESC:"
36                 printf " nfsd"
37                 start-stop-daemon --start --quiet \
38                     --exec $PREFIX/sbin/rpc.nfsd -- $RPCNFSDCOUNT
39                 printf " mountd"
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
44                 echo "."
45
46         else
47                 echo "Not starting $DESC: No exports."
48         fi
49         ;;
50
51   stop)
52         printf "Stopping $DESC: mountd"
53         start-stop-daemon --stop --oknodo --quiet \
54             --exec $PREFIX/sbin/rpc.mountd
55         printf " nfsd"
56         start-stop-daemon --stop --oknodo --quiet \
57             --name nfsd --user root --signal 2
58         echo "."
59
60         printf "Unexporting directories for $DESC..."
61         $PREFIX/sbin/exportfs -au
62         echo "done."
63         ;;
64
65   reload | force-reload)
66         printf "Re-exporting directories for $DESC..."
67         $PREFIX/sbin/exportfs -r
68         echo "done."
69         ;;
70
71   restart)
72         $0 stop
73         sleep 1
74         $0 start
75         ;;
76
77   *)
78         echo "Usage: nfs-kernel-server {start|stop|reload|force-reload|restart}"
79         exit 1
80         ;;
81 esac
82
83 exit 0
84