]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfsfs.init
- added -f to umount in stop). script will not hang up when volume is unreachable
[packages/nfs-utils.git] / nfsfs.init
1 #!/bin/sh
2 #
3 # nfsfs         Mount NFS filesystems.
4 #
5 # Version:      @(#) /etc/init.d/skeleton 1.01 26-Oct-1993
6 #
7 # Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
8 #
9 # chkconfig: 345 15 88
10 # description: Mounts and unmounts all Network File System (NFS) \
11 #              mount points.
12 #
13 # $Id$
14
15 # Source networking configuration.
16 if [ ! -f /etc/sysconfig/network ]; then
17     exit 0
18 fi
19
20 # Source function library.
21 . /etc/rc.d/init.d/functions
22
23 . /etc/sysconfig/network
24
25 # Check that networking is up.
26 if is_no "${NETWORKING}"; then
27         msg_network_down nfsfs
28         exit 1
29 fi
30
31 # See how we were called.
32 case "$1" in
33   start)
34         show "Mounting NFS filesystems"
35         busy
36         mount -a -t nfs
37         deltext
38         ok
39         touch /var/lock/subsys/nfsfs
40         ;;
41   stop)
42         if [ -f /proc/mounts ] ; then
43                 fsfile="/proc/mounts"
44         else
45                 fsfile="/etc/mtab"
46         fi
47
48         show "Unmounting NFS filesystems"
49         busy
50         remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
51         while [ -n "$remaining" -a 3 -gt 0 ]
52         do
53                 fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile`
54                 sleep 2
55                 fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile`
56                 umount -a -f -t nfs
57                 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
58         done
59         deltext
60         ok
61         rm -f /var/lock/subsys/nfsfs
62         ;;
63   status)
64         if [ -f /proc/mounts ] ; then
65                 echo "Configured NFS mountpoints:"
66                 grep -v '^#' /etc/fstab | \
67                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
68                 echo "Active NFS mountpoints:"
69                 grep -v '^#' /proc/mounts | \
70                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
71         else
72                 echo "/proc filesystem unavailable"
73         fi
74         ;;
75   restart)
76         $0 stop
77         $0 start
78         ;;
79   reload)
80         mount -a -t nfs
81         ;;
82   *)
83         msg_usage "$0 {start|stop|restart|reload|status}"
84         exit 1
85 esac
86
87 exit 0
88
This page took 0.067567 seconds and 3 git commands to generate.