5 # Required-Start: $portmap $time
7 # Default-Start: 2 3 4 5 S
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
24 PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
26 if [ -f $DEFAULTFILE ]; then
30 . /lib/lsb/init-functions
32 # Exit if required binaries are missing.
33 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
36 # Parse the fstab file, and determine whether we need idmapd and gssd. (The
37 # /etc/defaults settings, if any, will override our autodetection.) This code
38 # is partially adapted from the mountnfs.sh script in the sysvinit package.
43 if [ -f /etc/fstab ]; then
46 while read DEV MTPT FSTYPE OPTS REST
48 if [ "$FSTYPE" = "nfs4" ]; then
52 sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
62 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
63 # to autodetect whether there are NFSv4 exports or not, and idmapd is not a
64 # particularily heavy daemon, so we auto-enable it if we find an /etc/exports
65 # file. This does not mean that there are NFSv4 or other mounts active (or
66 # even that nfs-kernel-server is installed), but it matches what the "start"
67 # condition in nfs-kernel-server's init script does, which has a value in
70 if [ -f /etc/exports ] && grep -q '^[[:space:]]*[^#]*/' /etc/exports; then
74 case "$NEED_IDMAPD" in
78 NEED_IDMAPD=$AUTO_NEED_IDMAPD
86 NEED_GSSD=$AUTO_NEED_GSSD
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 if [ "$NEED_STATD" = yes ]; then
124 log_progress_msg "statd"
125 start-stop-daemon --start --oknodo --quiet \
126 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
128 if [ $RET != 0 ]; then
134 # Don't start idmapd and gssd if we don't have them (say, if /usr is not
136 [ -x /usr/sbin/rpc.idmapd ] || NEED_IDMAPD=no
137 [ -x /usr/sbin/rpc.gssd ] || NEED_GSSD=no
139 if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
143 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
145 if [ "$NEED_IDMAPD" = yes ]
147 log_progress_msg "idmapd"
148 start-stop-daemon --start --oknodo --quiet \
149 --exec /usr/sbin/rpc.idmapd
151 if [ $RET != 0 ]; then
156 if [ "$NEED_GSSD" = yes ]
158 do_modprobe rpcsec_gss_krb5
159 log_progress_msg "gssd"
161 # we need this available; better to fail now than
162 # mysteriously on the first mount
163 if ! grep -q -E '^nfs[ ]' /etc/services; then
164 log_action_end_msg 1 "broken /etc/services, please see /usr/share/doc/nfs-common/README.Debian.nfsv4"
168 start-stop-daemon --start --oknodo --quiet \
169 --exec /usr/sbin/rpc.gssd -- $RPCGSSDOPTS
171 if [ $RET != 0 ]; then
182 log_daemon_msg "Stopping $DESC"
184 if [ "$NEED_GSSD" = yes ]
186 log_progress_msg "gssd"
187 start-stop-daemon --stop --oknodo --quiet \
190 if [ $RET != 0 ]; then
195 if [ "$NEED_IDMAPD" = yes ]
197 log_progress_msg "idmapd"
198 start-stop-daemon --stop --oknodo --quiet \
201 if [ $RET != 0 ]; then
206 if [ "$NEED_STATD" = yes ]
208 log_progress_msg "statd"
209 start-stop-daemon --stop --oknodo --quiet \
212 if [ $RET != 0 ]; then
217 do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
222 if [ "$NEED_STATD" = yes ]
224 if ! pidof rpc.statd >/dev/null
226 echo "rpc.statd not running"
231 if [ "$NEED_GSSD" = yes ]
233 if ! pidof rpc.gssd >/dev/null
235 echo "rpc.gssd not running"
240 if [ "$NEED_IDMAPD" = yes ]
242 if ! pidof rpc.idmapd >/dev/null
244 echo "rpc.idmapd not running"
249 echo "all daemons running"
253 restart | force-reload)
260 log_success_msg "Usage: nfs-common {start|stop|status|restart}"