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