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 IDMAPD_PIDFILE=/var/run/rpc.idmapd.pid
23 PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
24 if [ -f $DEFAULTFILE ]; then
28 # Determine whether lockd daemon is required.
32 '' | [01].* | 2.[0123].* )
33 # Older kernels may or may not need a lockd daemon.
34 # We must assume they do, unless we can prove otherwise.
35 # (A false positive here results only in a harmless message.)
37 if test -f /proc/ksyms
39 grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
43 *) # Modern kernels (>= 2.4) start a lockd thread automatically.
50 # Exit if required binaries are missing.
51 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
52 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
53 [ -x /usr/sbin/rpc.idmapd ] || [ "$NEED_IDMAPD" = no ] || exit 0
56 modprobe -q $1 || true
60 if ! grep -E -qs "$1\$" /proc/filesystems
72 # See how we were called.
75 cd / # daemons should have root dir as cwd
76 printf "Starting $DESC:"
78 start-stop-daemon --start --quiet \
79 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
80 if [ "$NEED_LOCKD" = yes ]
83 start-stop-daemon --start --quiet \
84 --exec $PREFIX/sbin/rpc.lockd || true
86 if [ "$NEED_IDMAPD" = yes ]
89 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT;
92 start-stop-daemon --start --quiet \
93 --make-pidfile --pidfile $IDMAPD_PIDFILE \
94 --exec /usr/sbin/rpc.idmapd
101 printf "Stopping $DESC:"
102 if [ "$NEED_IDMAPD" = yes ]
105 start-stop-daemon --stop --oknodo --quiet \
106 --name rpc.idmapd --user 0
107 rm -f $IDMAPD_PIDFILE
109 if [ "$NEED_LOCKD" = yes ]
112 start-stop-daemon --stop --oknodo --quiet \
113 --name rpc.lockd --user 0 || true
116 start-stop-daemon --stop --oknodo --quiet \
117 --name rpc.statd --user 0
121 restart | force-reload)
128 echo "Usage: nfs-common {start|stop|restart}"