#! /bin/sh ### BEGIN INIT INFO # Provides: mountnfs # Required-Start: $local_fs # Required-Stop: # Should-Start: $network $portmap nfs-common udev-mtab # Default-Start: S # Default-Stop: # Short-Description: Wait for network file systems to be mounted # Description: Network file systems are mounted by # /etc/network/if-up.d/mountnfs in the background # when interfaces are brought up; this script waits # for them to be mounted before carrying on. ### END INIT INFO source /lib/lsb/init-functions source /lib/init/vars.sh source /lib/init/mount-functions.sh proc do_wait_async_mount { # Read through fstab line by line. If it is NFS, set the flag # for mounting NFS file systems. If any NFS partition is found # then wait around for it. setglobal waitnfs = '' for file in [$[eval ls $[fstab_files]]] { if test -f $file { while read DEV MTPT FSTYPE OPTS REST { match $DEV { with ""|\#* continue } match $OPTS { with noauto|*,noauto|noauto,*|*,noauto,* continue } match $FSTYPE { with nfs|nfs4|smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph with * continue } match $MTPT { with /usr/local|/usr/local/* with /usr|/usr/* setglobal waitnfs = ""$waitnfs $MTPT"" with /var|/var/* setglobal waitnfs = ""$waitnfs $MTPT"" } } < "$file" } } # Wait for each path, the timeout is for all of them as that's # really the maximum time we have to wait anyway setglobal TIMEOUT = '900' for mountpt in [$waitnfs] { log_action_begin_msg "Waiting for $mountpt" while ! mountpoint -q $mountpt { sleep 0.1 setglobal TIMEOUT = $shExpr(' $TIMEOUT - 1 ') if test $TIMEOUT -le 0 { log_action_end_msg 1 break } } if test $TIMEOUT -gt 0 { log_action_end_msg 0 } } } match $1 { with start # Using 'no !=' instead of 'yes =' to make sure async nfs # mounting is the default even without a value in # /etc/default/rcS if test no != $ASYNCMOUNTNFS { do_wait_async_mount } else { env FROMINITD=yes /etc/network/if-up.d/mountnfs } with restart|reload|force-reload echo "Error: argument '$1' not supported" > !2 exit 3 with stop|status # No-op with * echo "Usage: $0 start|stop" > !2 exit 3 } :