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
53 # FSTYPE "nfs" can be NFSv4 now
54 #if [ "$FSTYPE" = "nfs4" ]; then
59 sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
69 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
70 # to autodetect whether there are NFSv4 exports or not, and idmapd is not a
71 # particularily heavy daemon, so we auto-enable it if we find an /etc/exports
72 # file. This does not mean that there are NFSv4 or other mounts active (or
73 # even that nfs-kernel-server is installed), but it matches what the "start"
74 # condition in nfs-kernel-server's init script does, which has a value in
77 if [ -f /etc/exports ] && grep -q '^[[:space:]]*[^#]*/' /etc/exports; then
89 case "$NEED_IDMAPD" in
93 NEED_IDMAPD=$AUTO_NEED_IDMAPD
101 NEED_GSSD=$AUTO_NEED_GSSD
106 if [ -x /sbin/modprobe -a -f /proc/modules ]
108 modprobe -q "$1" || true
113 if ! grep -E -qs "$1\$" /proc/filesystems
117 if ! mountpoint -q "$2"
119 mount -t "$1" "$1" "$2"
126 if mountpoint -q "$1"
133 # See how we were called.
136 log_daemon_msg "Starting $DESC"
138 if [ "$NEED_STATD" = yes ]; then
139 log_progress_msg "statd"
141 # See if rpcbind is running
142 if [ -x /usr/sbin/rpcinfo ]; then
143 /usr/sbin/rpcinfo -p >/dev/null 2>&1
145 if [ $RET != 0 ]; then
147 log_warning_msg "Not starting: portmapper is not running"
151 start-stop-daemon --start --oknodo --quiet \
152 --pidfile /var/run/rpc.statd.pid \
153 --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
155 if [ $RET != 0 ]; then
159 mkdir -p /lib/init/rw/sendsigs.omit.d
160 rm -f /lib/init/rw/sendsigs.omit.d/statd
161 ln -s /var/run/rpc.statd.pid /lib/init/rw/sendsigs.omit.d/statd
165 # Don't start idmapd and gssd if we don't have them (say, if /usr is not
167 [ -x /usr/sbin/rpc.idmapd ] || NEED_IDMAPD=no
168 [ -x /usr/sbin/rpc.gssd ] || NEED_GSSD=no
170 if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
175 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
177 if [ "$NEED_IDMAPD" = yes ]
179 log_progress_msg "idmapd"
180 start-stop-daemon --start --oknodo --quiet \
181 --exec /usr/sbin/rpc.idmapd
183 if [ $RET != 0 ]; then
188 if [ "$NEED_GSSD" = yes ]
190 do_modprobe rpcsec_gss_krb5
191 log_progress_msg "gssd"
193 # we need this available; better to fail now than
194 # mysteriously on the first mount
195 if ! grep -q -E '^nfs[ ]' /etc/services; then
196 log_action_end_msg 1 "broken /etc/services, please see /usr/share/doc/nfs-common/README.Debian.nfsv4"
200 start-stop-daemon --start --oknodo --quiet \
201 --exec /usr/sbin/rpc.gssd -- $RPCGSSDOPTS
203 if [ $RET != 0 ]; then
214 log_daemon_msg "Stopping $DESC"
216 if [ "$NEED_GSSD" = yes ]
218 log_progress_msg "gssd"
219 start-stop-daemon --stop --oknodo --quiet \
222 if [ $RET != 0 ]; then
227 if [ "$NEED_IDMAPD" = yes ]
229 log_progress_msg "idmapd"
230 start-stop-daemon --stop --oknodo --quiet \
233 if [ $RET != 0 ]; then
238 if [ "$NEED_STATD" = yes ]
240 log_progress_msg "statd"
241 start-stop-daemon --stop --oknodo --quiet \
244 if [ $RET != 0 ]; then
249 do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
254 if [ "$NEED_STATD" = yes ]
256 if ! pidof rpc.statd >/dev/null
258 echo "rpc.statd not running"
263 if [ "$NEED_GSSD" = yes ]
265 if ! pidof rpc.gssd >/dev/null
267 echo "rpc.gssd not running"
272 if [ "$NEED_IDMAPD" = yes ]
274 if ! pidof rpc.idmapd >/dev/null
276 echo "rpc.idmapd not running"
281 echo "all daemons running"
285 restart | force-reload)
292 log_success_msg "Usage: nfs-common {start|stop|status|restart}"