]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfsfs.init
- change detection of nfs4; load nfs module in nfsfs.init
[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         if [ ! -f /var/lock/subsys/nfsfs ]; then
41             if [ "$NFSDTYPE" != "U" ] && grep -q nfs4 /proc/filesystems; then
42                 modprobe -s nfs > /dev/null 2>&1
43                 if [ "$(kernelverser)" -ge "002006" ]; then
44                     grep -q rpc_pipefs /proc/filesystems && \
45                     ! grep -q rpc_pipefs /proc/mounts && \
46                     run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
47                 fi
48                 if [ ! -f /var/lock/subsys/idmapd ]; then
49                     msg_starting "NFS idmapd"
50                     daemon rpc.idmapd $RPCIDMAPOPTIONS
51                 fi
52                 msg_starting "NFS gssd"
53                 daemon rpc.gssd -m $RPCGSSOPTIONS
54             fi
55             run_cmd "Mounting NFS filesystems" mount -a -t nfs
56             touch /var/lock/subsys/nfsfs
57         else
58             msg_already_running "NFSFS"
59         fi
60         ;;
61   stop)
62         if [ -f /proc/mounts ]; then
63                 fsfile="/proc/mounts"
64         else
65                 fsfile="/etc/mtab"
66         fi
67
68         show "Unmounting NFS filesystems"
69         busy
70         retry=3
71         remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
72         while [ -n "$remaining" -a $retry -gt 0 ]; do
73                 fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile`
74                 sleep 2
75                 fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile`
76                 umount -a -f -t nfs
77                 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
78                 retry=$(($retry-1))
79         done
80         ok
81         if [ "$NFSDTYPE" != "U" ] && grep -q nfs4 /proc/filesystems; then
82             msg_stopping "NFS gssd"
83             killproc rpc.gssd
84             if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfs ]; then
85                 msg_stopping "NFS idmapd"
86                 killproc rpc.idmapd
87                 rm -f /var/lock/subsys/idmapd
88             fi
89         fi
90         rm -f /var/lock/subsys/nfsfs
91         ;;
92   status)
93         if [ -f /proc/mounts ]; then
94                 echo "Configured NFS mountpoints:"
95                 grep -v '^#' /etc/fstab | \
96                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
97                 echo "Active NFS mountpoints:"
98                 grep -v '^#' /proc/mounts | \
99                   awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
100         else
101                 echo "/proc filesystem unavailable"
102         fi
103         ;;
104   restart)
105         $0 stop
106         $0 start
107         ;;
108   reload|force-reload)
109         mount -a -t nfs
110         ;;
111   *)
112         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
113         exit 3
114 esac
115
116 exit 0
This page took 0.108375 seconds and 4 git commands to generate.