]>
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 | # |
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. | |
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 JR |
26 | # Get service config |
27 | [ -f /etc/sysconfig/nfsclient ] && . /etc/sysconfig/nfsclient | |
28 | ||
9fddaaa8 | 29 | # Check that networking is up. |
ff100ffc | 30 | if 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 | |
35 | else | |
36 | exit 0 | |
9fddaaa8 JR |
37 | fi |
38 | ||
ad615b8a | 39 | start() { |
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 | |
52 | fi | |
53 | msg_starting "NFS gssd" | |
54 | daemon rpc.gssd -m $RPCGSSOPTIONS | |
55 | fi | |
28c13cdf | 56 | fi |
c70958a8 AM |
57 | run_cmd "Mounting NFS filesystems" mount -a -t nfs |
58 | touch /var/lock/subsys/nfsfs | |
59 | else | |
60 | msg_already_running "NFSFS" | |
61 | fi | |
ad615b8a ER |
62 | } |
63 | ||
64 | stop() { | |
5da51246 | 65 | if [ -f /proc/mounts ]; then |
eafe4dfc | 66 | fsfile="/proc/mounts" |
67 | else | |
68 | fsfile="/etc/mtab" | |
69 | fi | |
70 | ||
9fddaaa8 JR |
71 | show "Unmounting NFS filesystems" |
72 | busy | |
af9ed1fb | 73 | retry=3 |
c4b46c9c | 74 | remaining=$(awk '$3 == "nfs" {print $2}' $fsfile) |
af9ed1fb | 75 | while [ -n "$remaining" -a $retry -gt 0 ]; do |
c4b46c9c PG |
76 | fuser -msk -TERM `awk '$3 == "nfs" {print $2}' < $fsfile` |
77 | sleep 2 | |
78 | fuser -msk -KILL `awk '$3 == "nfs" {print $2}' < $fsfile` | |
e0421f53 | 79 | umount -a -f -t nfs |
764423e2 | 80 | remaining=$(awk '$3 == "nfs" {print $2}' $fsfile) |
af9ed1fb | 81 | retry=$(($retry-1)) |
c4b46c9c | 82 | done |
9fddaaa8 | 83 | ok |
2da61068 JR |
84 | if is_yes "$NFS4" ; then |
85 | if grep -q nfs4 /proc/filesystems; then | |
86 | msg_stopping "NFS gssd" | |
87 | killproc rpc.gssd | |
88 | if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfs ]; then | |
89 | msg_stopping "NFS idmapd" | |
90 | killproc rpc.idmapd | |
91 | rm -f /var/lock/subsys/idmapd | |
92 | fi | |
93 | fi | |
c70958a8 | 94 | fi |
9fddaaa8 | 95 | rm -f /var/lock/subsys/nfsfs |
ad615b8a ER |
96 | } |
97 | ||
98 | # See how we were called. | |
99 | case "$1" in | |
100 | start) | |
101 | start | |
102 | ;; | |
103 | stop) | |
104 | stop | |
9fddaaa8 JR |
105 | ;; |
106 | status) | |
5da51246 | 107 | if [ -f /proc/mounts ]; then |
9fddaaa8 | 108 | echo "Configured NFS mountpoints:" |
0c170055 JB |
109 | grep -v '^#' /etc/fstab | \ |
110 | awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}' | |
9fddaaa8 | 111 | echo "Active NFS mountpoints:" |
0c170055 JB |
112 | grep -v '^#' /proc/mounts | \ |
113 | awk '{ if ($3 ~ /^nfs$/ && $4 !~ /noauto/) print $2}' | |
9fddaaa8 JR |
114 | else |
115 | echo "/proc filesystem unavailable" | |
116 | fi | |
117 | ;; | |
118 | restart) | |
ad615b8a ER |
119 | stop |
120 | start | |
9fddaaa8 | 121 | ;; |
5246d326 | 122 | reload|force-reload) |
9fddaaa8 JR |
123 | mount -a -t nfs |
124 | ;; | |
125 | *) | |
5246d326 | 126 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
127 | exit 3 | |
9fddaaa8 JR |
128 | esac |
129 | ||
130 | exit 0 |