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.
39 if [ -f /etc/fstab ]; then
42 while read DEV MTPT FSTYPE OPTS REST
44 if [ "$FSTYPE" = "nfs4" ]; then
48 sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
58 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
59 # to autodetect whether there are NFSv4 exports or not, and idmapd is not a
60 # particularily heavy daemon, so we auto-enable it if we find an /etc/exports
61 # file. This does not mean that there are NFSv4 or other mounts active (or
62 # even that nfs-kernel-server is installed), but it matches what the "start"
63 # condition in nfs-kernel-server's init script does, which has a value in
66 if [ -f /etc/exports ]; then
71 case "$NEED_IDMAPD" in
75 NEED_IDMAPD=$AUTO_NEED_IDMAPD
83 NEED_GSSD=$AUTO_NEED_GSSD
87 # Exit if required binaries are missing.
88 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
89 [ -x /usr/sbin/rpc.idmapd ] || [ "$NEED_IDMAPD" = no ] || exit 0
90 [ -x /usr/sbin/rpc.gssd ] || [ "$NEED_GSSD" = no ] || exit 0
93 if [ -x /sbin/modprobe -a -f /proc/modules ]
95 modprobe -q "$1" || true
100 if ! grep -E -qs "$1\$" /proc/filesystems
104 if ! mountpoint -q "$2"
106 mount -t "$1" "$1" "$2"
113 if mountpoint -q "$1"
120 # See how we were called.
123 log_daemon_msg "Starting $DESC"
125 log_progress_msg "statd"
126 start-stop-daemon --start --oknodo --quiet \
127 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
133 if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
137 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
139 if [ "$NEED_IDMAPD" = yes ]
141 log_progress_msg "idmapd"
142 start-stop-daemon --start --oknodo --quiet \
143 --exec /usr/sbin/rpc.idmapd
149 if [ "$NEED_GSSD" = yes ]
151 do_modprobe rpcsec_gss_krb5
152 log_progress_msg "gssd"
154 # we need this available; better to fail now than
155 # mysteriously on the first mount
156 if ! grep -q -E '^nfs[ ]' /etc/services; then
157 log_action_end_msg 1 "broken /etc/services, please see /usr/share/doc/nfs-common/README.Debian.nfsv4"
161 start-stop-daemon --start --oknodo --quiet \
162 --exec /usr/sbin/rpc.gssd -- $RPCGSSDOPTS
174 log_daemon_msg "Stopping $DESC"
176 if [ "$NEED_GSSD" = yes ]
178 log_progress_msg "gssd"
179 start-stop-daemon --stop --oknodo --quiet \
186 if [ "$NEED_IDMAPD" = yes ]
188 log_progress_msg "idmapd"
189 start-stop-daemon --stop --oknodo --quiet \
196 log_progress_msg "statd"
197 start-stop-daemon --stop --oknodo --quiet \
203 do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
208 if ! pidof rpc.statd >/dev/null
210 echo "rpc.statd not running"
214 if [ "$NEED_GSSD" = yes ]
216 if ! pidof rpc.gssd >/dev/null
218 echo "rpc.statd running, but rpc.gssd halted"
223 if [ "$NEED_IDMAPD" = yes ]
225 if ! pidof rpc.idmapd >/dev/null
227 echo "rpc.statd running, but rpc.idmapd halted"
232 echo "rpc.statd running"
236 restart | force-reload)
243 log_success_msg "Usage: nfs-common {start|stop|status|restart}"