]> git.pld-linux.org Git - packages/nfs-utils.git/blame - nfsfs.init
- no need to mount rpc_pipefs here, idmapd will do/already did it for us
[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#
891a86c9 9# chkconfig: 345 16 80
ff100ffc 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
af75af5c 28[ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
2da61068 29
9fddaaa8 30# Check that networking is up.
ff100ffc 31if is_yes "${NETWORKING}"; then
b69cfb4d 32 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
ff100ffc 33 msg_network_down nfsfs
34 exit 1
35 fi
36else
37 exit 0
9fddaaa8
JR
38fi
39
af75af5c
JR
40if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
41 [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
42fi
43
ad615b8a 44start() {
c70958a8 45 if [ ! -f /var/lock/subsys/nfsfs ]; then
af75af5c
JR
46 # Set the ports lockd should listen on
47 if [ -n "$LOCKD_TCPPORT" ]; then
48 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
49 fi
50 if [ -n "$LOCKD_UDPPORT" ]; then
51 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
28c13cdf 52 fi
af75af5c
JR
53
54 # Special case /usr first
1fbf8b87 55 if ! awk '{ if ($2 == "/usr" && $3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) exit 1}' /etc/fstab ; then
af75af5c
JR
56 run_cmd "Mounting /usr filesystem" mount /usr
57 # In case of /usr over NFS idmapd, gssd and lockd may not start
58 # check if they're running and try to start them if not
59 /sbin/service idmapd status >/dev/null || /sbin/service idmapd start
60 /sbin/service gssd status >/dev/null || /sbin/service gssd start
61 /sbin/service nfslock status >/dev/null || /sbin/service nfslock start
62 fi
63 run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4
07a92029 64 touch /var/lock/subsys/nfsfs
af75af5c 65
c70958a8
AM
66 else
67 msg_already_running "NFSFS"
68 fi
ad615b8a
ER
69}
70
71stop() {
5da51246 72 if [ -f /proc/mounts ]; then
eafe4dfc 73 fsfile="/proc/mounts"
74 else
75 fsfile="/etc/mtab"
76 fi
77
07a92029
JR
78 show "Unmounting NFS filesystems"
79 busy
80 retry=3
af75af5c 81 remaining=$(awk '$3 ~ /^nfs(4$|$)/ {print $2}' $fsfile)
07a92029 82 while [ -n "$remaining" -a $retry -gt 0 ]; do
af75af5c 83 fuser -msk -TERM `awk '$3 ~ /^nfs(4$|$)/ {print $2}' < $fsfile`
07a92029 84 sleep 2
af75af5c
JR
85 fuser -msk -KILL `awk '$3 ~ /^nfs(4$|$)/ {print $2}' < $fsfile`
86 umount -a -f -t nfs,nfs4
87 remaining=$(awk '$3 ~ /^nfs(4$|$)/ {print $2}' $fsfile)
07a92029
JR
88 retry=$(($retry-1))
89 done
90 ok
9fddaaa8 91 rm -f /var/lock/subsys/nfsfs
ad615b8a
ER
92}
93
94# See how we were called.
95case "$1" in
96 start)
97 start
98 ;;
99 stop)
100 stop
9fddaaa8
JR
101 ;;
102 status)
5da51246 103 if [ -f /proc/mounts ]; then
9fddaaa8 104 echo "Configured NFS mountpoints:"
0c170055 105 grep -v '^#' /etc/fstab | \
af75af5c 106 awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}'
9fddaaa8 107 echo "Active NFS mountpoints:"
0c170055 108 grep -v '^#' /proc/mounts | \
af75af5c 109 awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}'
9fddaaa8
JR
110 else
111 echo "/proc filesystem unavailable"
112 fi
113 ;;
114 restart)
ad615b8a
ER
115 stop
116 start
9fddaaa8 117 ;;
5246d326 118 reload|force-reload)
af75af5c 119 mount -a -t nfs,nfs4
9fddaaa8
JR
120 ;;
121 *)
5246d326 122 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
123 exit 3
9fddaaa8
JR
124esac
125
126exit 0
This page took 0.096433 seconds and 4 git commands to generate.