3 # nfs-common This shell script takes care of starting and stopping
4 # common daemons required for NFS clients and servers.
7 # description: NFS is a popular protocol for file sharing across \
8 # TCP/IP networks. This service provides NFS file \
9 # locking functionality.
15 DESC="NFS common utilities"
18 DEFAULTFILE=/etc/default/nfs-common
22 if [ -f $DEFAULTFILE ]; then
26 # Determine whether lockd daemon is required.
30 '' | [01].* | 2.[0123].* )
31 # Older kernels may or may not need a lockd daemon.
32 # We must assume they do, unless we can prove otherwise.
33 # (A false positive here results only in a harmless message.)
35 if test -f /proc/ksyms
37 grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
41 *) # Modern kernels (>= 2.4) start a lockd thread automatically.
48 # Exit if required binaries are missing.
49 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
50 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
51 [ -x /usr/sbin/rpc.idmapd ] || [ "$NEED_IDMAPD" = no ] || exit 0
53 # See how we were called.
56 cd / # daemons should have root dir as cwd
57 printf "Starting $DESC:"
59 start-stop-daemon --start --quiet \
60 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
61 if [ "$NEED_LOCKD" = yes ]
64 start-stop-daemon --start --quiet \
65 --exec $PREFIX/sbin/rpc.lockd || true
67 if [ "$NEED_IDMAPD" = yes ]
70 start-stop-daemon --start --quiet \
71 --exec /usr/sbin/rpc.idmapd
77 printf "Stopping $DESC:"
78 if [ "$NEED_IDMAPD" = yes ]
81 start-stop-daemon --stop --oknodo --quiet \
82 --name rpc.idmapd --user 0
84 if [ "$NEED_LOCKD" = yes ]
87 start-stop-daemon --stop --oknodo --quiet \
88 --name rpc.lockd --user 0 || true
91 start-stop-daemon --stop --oknodo --quiet \
92 --name rpc.statd --user 0
96 restart | force-reload)
103 echo "Usage: nfs-common {start|stop|restart}"