5 # Required-Start: $time
7 # Default-Start: 2 3 4 5
9 # Short-Description: NFS support files common to client and server
10 # Description: NFS is a popular protocol for file sharing across
11 # TCP/IP networks. This service provides various
12 # support functions for NFS mounts.
16 DESC="NFS common utilities"
19 DEFAULTFILE=/etc/default/nfs-common
23 PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
25 if [ -f $DEFAULTFILE ]; then
29 . /lib/lsb/init-functions
32 # Parse the fstab file, and determine whether we need idmapd and gssd. (The
33 # /etc/defaults settings, if any, will override our autodetection.) This code
34 # is partially adapted from the mountnfs.sh script in the sysvinit package.
41 while read DEV MTPT FSTYPE OPTS REST
43 if [ "$FSTYPE" = "nfs4" ]; then
47 sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
56 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
57 # to autodetect whether there are NFSv4 exports or not, and idmapd is not a
58 # particularily heavy daemon, so we auto-enable it if we find an /etc/exports
59 # file. This does not mean that there are NFSv4 or other mounts active (or
60 # even that nfs-kernel-server is installed), but it matches what the "start"
61 # condition in nfs-kernel-server's init script does, which has a value in
64 if [ -f /etc/exports ]; then
69 case "$NEED_IDMAPD" in
73 NEED_IDMAPD=$AUTO_NEED_IDMAPD
81 NEED_GSSD=$AUTO_NEED_GSSD
85 # Exit if required binaries are missing.
86 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
87 [ -x /usr/sbin/rpc.idmapd ] || [ "$NEED_IDMAPD" = no ] || exit 0
88 [ -x /usr/sbin/rpc.gssd ] || [ "$NEED_GSSD" = no ] || exit 0
91 if [ -x /sbin/modprobe -a -f /proc/modules ]
93 modprobe -q "$1" || true
98 if ! grep -E -qs "$1\$" /proc/filesystems
102 if ! mountpoint -q "$2"
104 mount -t "$1" "$1" "$2"
111 if mountpoint -q "$1"
118 # See how we were called.
121 log_daemon_msg "Starting $DESC"
123 log_progress_msg "statd"
124 start-stop-daemon --start --oknodo --quiet \
125 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
131 if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
135 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
137 if [ "$NEED_IDMAPD" = yes ]
139 log_progress_msg "idmapd"
140 start-stop-daemon --start --oknodo --quiet \
141 --exec /usr/sbin/rpc.idmapd
147 if [ "$NEED_GSSD" = yes ]
149 do_modprobe rpcsec_gss_krb5
150 log_progress_msg "gssd"
152 # we need this available; better to fail now than
153 # mysteriously on the first mount
154 if ! grep -q -E '^nfs[ ]' /etc/services; then
155 log_action_end_msg 1 "broken /etc/services, please see /usr/share/doc/nfs-common/README.Debian.nfsv4"
159 start-stop-daemon --start --oknodo --quiet \
160 --exec /usr/sbin/rpc.gssd -- $RPCGSSDOPTS
172 log_daemon_msg "Stopping $DESC"
174 if [ "$NEED_GSSD" = yes ]
176 log_progress_msg "gssd"
177 start-stop-daemon --stop --oknodo --quiet \
184 if [ "$NEED_IDMAPD" = yes ]
186 log_progress_msg "idmapd"
187 start-stop-daemon --stop --oknodo --quiet \
194 log_progress_msg "statd"
195 start-stop-daemon --stop --oknodo --quiet \
201 do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
206 if ! pidof rpc.statd >/dev/null
208 echo "rpc.statd not running"
212 if [ "$NEED_GSSD" = yes ]
214 if ! pidof rpc.gssd >/dev/null
216 echo "rpc.statd running, but rpc.gssd halted"
221 if [ "$NEED_IDMAPD" = yes ]
223 if ! pidof rpc.idmapd >/dev/null
225 echo "rpc.statd running, but rpc.idmapd halted"
230 echo "rpc.statd running"
234 restart | force-reload)
241 log_success_msg "Usage: nfs-common {start|stop|status|restart}"