]> git.pld-linux.org Git - packages/nfs-utils.git/blame - nfsfs.init
- rel 5
[packages/nfs-utils.git] / nfsfs.init
CommitLineData
9fddaaa8
JR
1#!/bin/sh
2#
ff100ffc 3# nfsfs Mount NFS filesystems.
9fddaaa8 4#
ff100ffc 5# Version: @(#) /etc/init.d/skeleton 1.01 26-Oct-1993
9fddaaa8 6#
ff100ffc 7# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
9fddaaa8 8#
ff100ffc 9# chkconfig: 345 15 88
10# description: Mounts and unmounts all Network File System (NFS) \
11# mount points.
9fddaaa8
JR
12#
13# $Id$
14
15# Source networking configuration.
16if [ ! -f /etc/sysconfig/network ]; then
ff100ffc 17 exit 0
9fddaaa8
JR
18fi
19
20# Source function library.
21. /etc/rc.d/init.d/functions
22
ff100ffc 23# Get network config
9fddaaa8
JR
24. /etc/sysconfig/network
25
2da61068 26# Get service config
eed927a9 27[ -f /etc/sysconfig/nfsfs ] && . /etc/sysconfig/nfsfs
2da61068 28
9fddaaa8 29# Check that networking is up.
ff100ffc 30if is_yes "${NETWORKING}"; then
b69cfb4d 31 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
ff100ffc 32 msg_network_down nfsfs
33 exit 1
34 fi
35else
36 exit 0
9fddaaa8
JR
37fi
38
ad615b8a 39start() {
c70958a8 40 if [ ! -f /var/lock/subsys/nfsfs ]; then
2da61068
JR
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
bdfce34e
JR
52 [ $? -eq 0 ] && touch /var/lock/subsys/idmapd
53 fi
54 if [ ! -f /var/lock/subsys/gssd ]; then
55 msg_starting "NFS gssd"
56 daemon rpc.gssd -m $RPCGSSOPTIONS
57 [ $? -eq 0 ] && touch /var/lock/subsys/gssd
2da61068 58 fi
2da61068 59 fi
28c13cdf 60 fi
c70958a8
AM
61 run_cmd "Mounting NFS filesystems" mount -a -t nfs
62 touch /var/lock/subsys/nfsfs
63 else
64 msg_already_running "NFSFS"
65 fi
ad615b8a
ER
66}
67
68stop() {
5da51246 69 if [ -f /proc/mounts ]; then
eafe4dfc 70 fsfile="/proc/mounts"
71 else
72 fsfile="/etc/mtab"
73 fi
74
9fddaaa8
JR
75 show "Unmounting NFS filesystems"
76 busy
af9ed1fb 77 retry=3
c4b46c9c 78 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
af9ed1fb 79 while [ -n "$remaining" -a $retry -gt 0 ]; do
c4b46c9c
PG
80 fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile`
81 sleep 2
82 fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile`
e0421f53 83 umount -a -f -t nfs
764423e2 84 remaining=$(awk '$3 == "nfs" {print $2}' $fsfile)
af9ed1fb 85 retry=$(($retry-1))
c4b46c9c 86 done
9fddaaa8 87 ok
2da61068
JR
88 if is_yes "$NFS4" ; then
89 if grep -q nfs4 /proc/filesystems; then
bdfce34e
JR
90 if [ -f /var/lock/subsys/gssd ]; then
91 msg_stopping "NFS gssd"
92 killproc rpc.gssd
93 rm -f /var/lock/subsys/gssd
94 fi
2da61068
JR
95 if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfs ]; then
96 msg_stopping "NFS idmapd"
97 killproc rpc.idmapd
98 rm -f /var/lock/subsys/idmapd
99 fi
100 fi
c70958a8 101 fi
9fddaaa8 102 rm -f /var/lock/subsys/nfsfs
ad615b8a
ER
103}
104
105# See how we were called.
106case "$1" in
107 start)
108 start
109 ;;
110 stop)
111 stop
9fddaaa8
JR
112 ;;
113 status)
5da51246 114 if [ -f /proc/mounts ]; then
9fddaaa8 115 echo "Configured NFS mountpoints:"
0c170055
JB
116 grep -v '^#' /etc/fstab | \
117 awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
9fddaaa8 118 echo "Active NFS mountpoints:"
0c170055
JB
119 grep -v '^#' /proc/mounts | \
120 awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}'
9fddaaa8
JR
121 else
122 echo "/proc filesystem unavailable"
123 fi
124 ;;
125 restart)
ad615b8a
ER
126 stop
127 start
9fddaaa8 128 ;;
5246d326 129 reload|force-reload)
9fddaaa8
JR
130 mount -a -t nfs
131 ;;
132 *)
5246d326 133 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
134 exit 3
9fddaaa8
JR
135esac
136
137exit 0
This page took 0.066686 seconds and 4 git commands to generate.