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