3 # nfsfs Mount NFS filesystems.
6 # description: Mounts and unmounts all Network File System (NFS) \
9 # Source networking configuration.
10 if [ ! -f /etc/sysconfig/network ]; then
14 # Source function library.
15 . /etc/rc.d/init.d/functions
18 . /etc/sysconfig/network
21 [ -f /etc/sysconfig/nfsfs ] && . /etc/sysconfig/nfsfs
22 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
24 # Check that networking is up.
25 if is_yes "${NETWORKING}"; then
26 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
27 msg_network_down nfsfs
34 if [ "$1" != "stop" ]; then
35 check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
38 if [ -z "$NFSUMOUNT_IGNORE" ]; then
39 NFSUMOUNT_IGNORE="/ /usr"
43 if [ -f /var/lock/subsys/nfsfs ]; then
44 msg_already_running "NFSFS"
48 # Set the ports lockd should listen on
49 if [ -n "$LOCKD_TCPPORT" ]; then
50 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
52 if [ -n "$LOCKD_UDPPORT" ]; then
53 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
56 run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4
57 touch /var/lock/subsys/nfsfs
61 if [ -f /proc/mounts ]; then
67 show "Unmounting NFS filesystems"
70 remaining=$(awk -v ig="^($NFSUMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
71 $3 ~ /^nfs(4$|$)/ && $2 !~ ig {print $2}' $fsfile)
72 while [ -n "$remaining" -a $retry -gt 0 ]; do
73 fuser -msk -TERM `awk -v ig="^($NFSUMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
74 $3 ~ /^nfs(4$|$)/ && $2 !~ ig {print $2}' $fsfile`
76 fuser -msk -KILL `awk -v ig="^($NFSUMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
77 $3 ~ /^nfs(4$|$)/ && $2 !~ ig {print $2}' $fsfile`
78 # Sort filesystems to unmount in reverse order
80 for r in $(awk -v ig="^($NFSUMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
81 $3 ~ /^nfs(4$|$)/ && $2 !~ ig {print $2}' $fsfile) ; do
87 remaining=$(awk -v ig="^($NFSUMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
88 $3 ~ /^nfs(4$|$)/ && $2 !~ ig {print $2}' $fsfile)
92 rm -f /var/lock/subsys/nfsfs
95 # See how we were called.
111 if [ -f /proc/mounts ]; then
112 echo "Configured NFS mountpoints:"
113 grep -v '^#' /etc/fstab | \
114 awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}'
115 echo "Active NFS mountpoints:"
116 grep -v '^#' /proc/mounts | \
117 awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}'
119 echo "/proc filesystem unavailable"
123 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"