]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfsfs.init
- mount /proc/fs/nfsd when running on 2.6 kernel
[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 # Get network config
24 . /etc/sysconfig/network
25
26 # Check that networking is up.
27 if is_yes "${NETWORKING}"; then
28         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
29                 msg_network_down nfsfs
30                 exit 1
31         fi
32 else
33         exit 0
34 fi
35
36
37 # See how we were called.
38 case "$1" in
39   start)
40         modprobe -s nfsd > /dev/null 2>&1
41         
42         if [ "$(kernelverser)" -ge "002006" ] && \
43                 grep -q nfsd /proc/filesystems && \
44                 ! grep -q nfsd /proc/mounts; then
45                         run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
46         fi
47         run_cmd "Mounting NFS filesystems" mount -a -t nfs
48         touch /var/lock/subsys/nfsfs
49         ;;
50   stop)
51         if [ -f /proc/mounts ]; then
52                 fsfile="/proc/mounts"
53         else
54                 fsfile="/etc/mtab"
55         fi
56
57         show "Unmounting NFS filesystems"
58         busy
59         retry=3
60         remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
61         while [ -n "$remaining" -a $retry -gt 0 ]; do
62                 fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile`
63                 sleep 2
64                 fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile`
65                 umount -a -f -t nfs
66                 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
67                 retry=$(($retry-1))
68         done
69         ok
70         rm -f /var/lock/subsys/nfsfs
71         ;;
72   status)
73         if [ -f /proc/mounts ]; then
74                 echo "Configured NFS mountpoints:"
75                 grep -v '^#' /etc/fstab | \
76                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
77                 echo "Active NFS mountpoints:"
78                 grep -v '^#' /proc/mounts | \
79                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
80         else
81                 echo "/proc filesystem unavailable"
82         fi
83         ;;
84   restart)
85         $0 stop
86         $0 start
87         ;;
88   reload|force-reload)
89         mount -a -t nfs
90         ;;
91   *)
92         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
93         exit 3
94 esac
95
96 exit 0
This page took 0.036889 seconds and 4 git commands to generate.