]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfsfs.init
- rel 7; rebuild
[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 # Get service config
27 [ -f /etc/sysconfig/nfsclient ] && . /etc/sysconfig/nfsclient
28
29 # Check that networking is up.
30 if is_yes "${NETWORKING}"; then
31         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
32                 msg_network_down nfsfs
33                 exit 1
34         fi
35 else
36         exit 0
37 fi
38
39 start() {
40         if [ ! -f /var/lock/subsys/nfsfs ]; then
41                 if is_yes "$NFS4" ; then
42                     if grep -q nfs4 /proc/filesystems; then
43                         modprobe -s nfs > /dev/null 2>&1
44                         if [ "$(kernelverser)" -ge "002006" ]; then
45                             grep -q rpc_pipefs /proc/filesystems && \
46                             ! grep -q rpc_pipefs /proc/mounts && \
47                             run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
48                         fi
49                         if [ ! -f /var/lock/subsys/idmapd ]; then
50                             msg_starting "NFS idmapd"
51                             daemon rpc.idmapd $RPCIDMAPOPTIONS
52                         fi
53                         msg_starting "NFS gssd"
54                         daemon rpc.gssd -m $RPCGSSOPTIONS
55                     fi
56                 fi
57             run_cmd "Mounting NFS filesystems" mount -a -t nfs
58             touch /var/lock/subsys/nfsfs
59         else
60             msg_already_running "NFSFS"
61         fi
62 }
63
64 stop() {
65         if [ -f /proc/mounts ]; then
66                 fsfile="/proc/mounts"
67         else
68                 fsfile="/etc/mtab"
69         fi
70
71         show "Unmounting NFS filesystems"
72         busy
73         retry=3
74         remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
75         while [ -n "$remaining" -a $retry -gt 0 ]; do
76                 fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile`
77                 sleep 2
78                 fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile`
79                 umount -a -f -t nfs
80                 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
81                 retry=$(($retry-1))
82         done
83         ok
84         if is_yes "$NFS4" ; then
85                 if grep -q nfs4 /proc/filesystems; then
86                     msg_stopping "NFS gssd"
87                     killproc rpc.gssd
88                     if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfs ]; then
89                         msg_stopping "NFS idmapd"
90                         killproc rpc.idmapd
91                         rm -f /var/lock/subsys/idmapd
92                     fi
93                 fi
94         fi
95         rm -f /var/lock/subsys/nfsfs
96 }
97
98 # See how we were called.
99 case "$1" in
100   start)
101         start
102         ;;
103   stop)
104         stop
105         ;;
106   status)
107         if [ -f /proc/mounts ]; then
108                 echo "Configured NFS mountpoints:"
109                 grep -v '^#' /etc/fstab | \
110                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
111                 echo "Active NFS mountpoints:"
112                 grep -v '^#' /proc/mounts | \
113                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
114         else
115                 echo "/proc filesystem unavailable"
116         fi
117         ;;
118   restart)
119         stop
120         start
121         ;;
122   reload|force-reload)
123         mount -a -t nfs
124         ;;
125   *)
126         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
127         exit 3
128 esac
129
130 exit 0
This page took 0.03098 seconds and 3 git commands to generate.