]>
Commit | Line | Data |
---|---|---|
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 | # |
af75af5c | 9 | # chkconfig: 345 15 83 |
ff100ffc | 10 | # description: Mounts and unmounts all Network File System (NFS) \ |
11 | # mount points. | |
9fddaaa8 JR |
12 | # |
13 | # $Id$ | |
14 | ||
15 | # Source networking configuration. | |
16 | if [ ! -f /etc/sysconfig/network ]; then | |
ff100ffc | 17 | exit 0 |
9fddaaa8 JR |
18 | fi |
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 | 31 | if 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 | |
36 | else | |
37 | exit 0 | |
9fddaaa8 JR |
38 | fi |
39 | ||
af75af5c JR |
40 | if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then |
41 | [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0 | |
42 | fi | |
43 | ||
ad615b8a | 44 | start() { |
c70958a8 | 45 | if [ ! -f /var/lock/subsys/nfsfs ]; then |
af75af5c JR |
46 | if ! grep -q rpc_pipefs /proc/mounts ; then |
47 | modprobe -s sunrpc > /dev/null 2>&1 | |
48 | run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" \ | |
49 | mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs | |
50 | fi | |
51 | ||
52 | # Set the ports lockd should listen on | |
53 | if [ -n "$LOCKD_TCPPORT" ]; then | |
54 | /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1 | |
55 | fi | |
56 | if [ -n "$LOCKD_UDPPORT" ]; then | |
57 | /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1 | |
28c13cdf | 58 | fi |
af75af5c JR |
59 | |
60 | # Special case /usr first | |
61 | if awk '{ if ($2 == "/usr" && $3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) exit 1}' /etc/fstab ; then | |
62 | run_cmd "Mounting /usr filesystem" mount /usr | |
63 | # In case of /usr over NFS idmapd, gssd and lockd may not start | |
64 | # check if they're running and try to start them if not | |
65 | /sbin/service idmapd status >/dev/null || /sbin/service idmapd start | |
66 | /sbin/service gssd status >/dev/null || /sbin/service gssd start | |
67 | /sbin/service nfslock status >/dev/null || /sbin/service nfslock start | |
68 | fi | |
69 | run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4 | |
07a92029 | 70 | touch /var/lock/subsys/nfsfs |
af75af5c | 71 | |
c70958a8 AM |
72 | else |
73 | msg_already_running "NFSFS" | |
74 | fi | |
ad615b8a ER |
75 | } |
76 | ||
77 | stop() { | |
5da51246 | 78 | if [ -f /proc/mounts ]; then |
eafe4dfc | 79 | fsfile="/proc/mounts" |
80 | else | |
81 | fsfile="/etc/mtab" | |
82 | fi | |
83 | ||
07a92029 JR |
84 | show "Unmounting NFS filesystems" |
85 | busy | |
86 | retry=3 | |
af75af5c | 87 | remaining=$(awk '$3 ~ /^nfs(4$|$)/ {print $2}' $fsfile) |
07a92029 | 88 | while [ -n "$remaining" -a $retry -gt 0 ]; do |
af75af5c | 89 | fuser -msk -TERM `awk '$3 ~ /^nfs(4$|$)/ {print $2}' < $fsfile` |
07a92029 | 90 | sleep 2 |
af75af5c JR |
91 | fuser -msk -KILL `awk '$3 ~ /^nfs(4$|$)/ {print $2}' < $fsfile` |
92 | umount -a -f -t nfs,nfs4 | |
93 | remaining=$(awk '$3 ~ /^nfs(4$|$)/ {print $2}' $fsfile) | |
07a92029 JR |
94 | retry=$(($retry-1)) |
95 | done | |
96 | ok | |
9fddaaa8 | 97 | rm -f /var/lock/subsys/nfsfs |
ad615b8a ER |
98 | } |
99 | ||
100 | # See how we were called. | |
101 | case "$1" in | |
102 | start) | |
103 | start | |
104 | ;; | |
105 | stop) | |
106 | stop | |
9fddaaa8 JR |
107 | ;; |
108 | status) | |
5da51246 | 109 | if [ -f /proc/mounts ]; then |
9fddaaa8 | 110 | echo "Configured NFS mountpoints:" |
0c170055 | 111 | grep -v '^#' /etc/fstab | \ |
af75af5c | 112 | awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}' |
9fddaaa8 | 113 | echo "Active NFS mountpoints:" |
0c170055 | 114 | grep -v '^#' /proc/mounts | \ |
af75af5c | 115 | awk '{ if ($3 ~ /^nfs(4$|$)/ && $4 !~ /noauto/) print $2}' |
9fddaaa8 JR |
116 | else |
117 | echo "/proc filesystem unavailable" | |
118 | fi | |
119 | ;; | |
120 | restart) | |
ad615b8a ER |
121 | stop |
122 | start | |
9fddaaa8 | 123 | ;; |
5246d326 | 124 | reload|force-reload) |
af75af5c | 125 | mount -a -t nfs,nfs4 |
9fddaaa8 JR |
126 | ;; |
127 | *) | |
5246d326 | 128 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
129 | exit 3 | |
9fddaaa8 JR |
130 | esac |
131 | ||
132 | exit 0 |