/[packages]/cauldron/nfs-utils/current/SOURCES/nfs-server.init
ViewVC logotype

Contents of /cauldron/nfs-utils/current/SOURCES/nfs-server.init

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49044 - (show annotations) (download)
Tue Feb 8 16:36:05 2011 UTC (13 years, 2 months ago) by ennael
File size: 4284 byte(s)
imported package nfs-utils
1 #!/bin/sh
2 # $Id: nfs-server.init 531794 2010-04-05 17:40:24Z guillomovitch $
3
4 # chkconfig: 345 60 20
5 # description: Kernel NFS server support
6
7 ### BEGIN INIT INFO
8 # Provides: nfs-server
9 # Required-Start: nfs-common $named
10 # Required-Stop: nfs-common $named
11 # Default-Start: 3 4 5
12 # Default-Stop: 0 1 6
13 # Short-Description: Kernel NFS server support
14 # Description: NFS is a popular protocol for file sharing across
15 # TCP/IP networks. This service provides NFS server
16 # functionality, which is configured via the
17 # /etc/exports file.
18 ### END INIT INFO
19
20 # Source function library.
21 . /etc/rc.d/init.d/functions
22
23 # Source networking configuration.
24 . /etc/sysconfig/network
25
26 # Check that networking is up.
27 [ "${NETWORKING}" = "no" ] && exit 0
28
29 # fail if /etc/exports doesn't exist
30 if [ ! -f /etc/exports ]; then
31 echo "/etc/exports does not exist"
32 exit 1
33 fi
34
35 # Read config
36 NAME="NFS kernel daemon"
37 LOCKFILE=/var/lock/subsys/nfs-server
38 PROCNFSD_MOUNTPOINT=/proc/fs/nfsd
39 RPCNFSDCOUNT=8
40 RPCMOUNTD_OPTIONS=
41 NEED_SVCGSSD=no
42 RPCSVCGSSD_OPTIONS=
43 NEED_QUOTAD=
44 RPCRQUOTAD_OPTIONS=
45 [ -f /etc/sysconfig/nfs-server ] && . /etc/sysconfig/nfs-server
46
47 # Parse the fstab file, and determine whether we need quotad
48 if grep -q '^[^#]*quota' /etc/fstab; then
49 AUTO_NEED_QUOTAD=yes
50 else
51 AUTO_NEED_QUOTAD=no
52 fi
53
54 case "$NEED_QUOTAD" in
55 yes|no)
56 ;;
57 *)
58 NEED_QUOTAD=$AUTO_NEED_QUOTAD
59 ;;
60 esac
61
62 do_modprobe() {
63 if [ -x /sbin/modprobe -a -f /proc/modules ]; then
64 modprobe -q "$1" || true
65 fi
66 }
67
68 do_mount() {
69 if ! grep -E -qs "$1\$" /proc/filesystems; then
70 return 1
71 fi
72 if ! mountpoint -q "$2"; then
73 mount -t "$1" "$1" "$2"
74 return
75 fi
76 return 0
77 }
78
79 start() {
80 if [ ! -f $LOCKFILE ]; then
81 do_modprobe nfsd
82
83 if ! do_mount nfsd $PROCNFSD_MOUNTPOINT; then
84 NEED_SVCGSSD=no
85 fi
86
87 echo -n "Exporting directories for $NAME..."
88 exportfs -r
89 rc=$?
90 echo
91 if [ $rc != 0 ]; then
92 return $rc
93 fi
94
95 echo "Starting $NAME"
96 echo -n "Starting nfsd"
97 daemon rpc.nfsd $RPCNFSD_OPTIONS $RPCNFSDCOUNT
98 rc=$?
99 echo
100 if [ $rc != 0 ]; then
101 return $rc
102 fi
103
104 if [ "$NEED_SVCGSSD" = "yes" ]; then
105 echo -n "Starting rpc.svcgssd"
106 daemon rpc.svcgssd $RPCSVCGSSD_OPTIONS
107 rc=$?
108 echo
109 if [ $rc != 0 ]; then
110 return $rc
111 fi
112 fi
113
114 if [ "$NEED_QUOTAD" = "yes" -a -x /usr/sbin/rpc.rquotad ]; then
115 echo -n "Starting rpc.rquotad"
116 daemon rpc.rquotad $RPCRQUOTAD_OPTIONS
117 rc=$?
118 echo
119 if [ $rc != 0 ]; then
120 return $rc
121 fi
122 fi
123
124 if pidof rpc.idmapd >/dev/null; then
125 echo -n "Reloading rpc.idmapd"
126 killproc rpc.idmapd -HUP
127 rc=$?
128 echo
129 fi
130
131 echo -n "Starting rpc.mountd"
132 daemon rpc.mountd $RPCMOUNTD_OPTIONS
133 rc=$?
134 echo
135 if [ $rc != 0 ]; then
136 return $rc
137 fi
138
139 touch $LOCKFILE
140 fi
141 return 0
142 }
143
144 stop() {
145 echo "Stopping $NAME"
146
147 echo -n "Stopping rpc.mountd:"
148 killproc rpc.mountd
149 rc=$?
150 echo
151 if [ $rc != 0 ]; then
152 return $rc
153 fi
154
155 if [ "$NEED_SVCGSSD" = "yes" ]; then
156 echo -n "Stopping rpc.svcgssd:"
157 killproc rpc.svcgssd
158 rc=$?
159 echo
160 if [ $rc != 0 ]; then
161 return $rc
162 fi
163 fi
164
165 if [ "$NEED_QUOTAD" = "yes" -a -x /usr/sbin/rpc.rquotad ]; then
166 echo -n "Stopping rpc.rquotad:"
167 killproc rpc.rquotad
168 rc=$?
169 echo
170 if [ $rc != 0 ]; then
171 return $rc
172 fi
173 fi
174
175 echo -n "Stopping nfsd:"
176 killproc nfsd
177 rc=$?
178 echo
179 if [ $rc != 0 ]; then
180 return $rc
181 fi
182
183 echo -n "Unexporting directories for $NAME..."
184 exportfs -au
185 rc=$?
186 echo
187 if [ $rc != 0 ]; then
188 return $rc
189 fi
190
191 if mountpoint -q /proc/nfs/nfsd; then
192 exportfs -f
193 fi
194
195 rm -f $LOCKFILE
196 return 0
197 }
198
199 reload() {
200 echo -n "Re-exporting directories for $NAME..."
201 exportfs -r
202 rc=$?
203 echo
204 return $rc
205 }
206
207 # See how we were called.
208 case "$1" in
209 start)
210 start
211 ;;
212 stop)
213 stop
214 ;;
215 status)
216 status nfsd
217 status rpc.mountd
218 if [ "$NEED_QUOTAD" = "yes" -a -x /usr/sbin/rpc.rquotad ]; then
219 status rpc.rquotad
220 fi
221 if [ "$NEED_SVCGSSD" = yes ]; then
222 status rpc.svcgssd
223 fi
224 ;;
225 reload)
226 reload
227 ;;
228 restart)
229 stop
230 sleep 1
231 start
232 ;;
233 *)
234 echo "Usage: $0 {start|stop|restart|reload|status}"
235 exit 1
236 ;;
237 esac
238
239 exit 0

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30