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