1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/sh
#RCUPDATE:3 4:74:This line is required for script management
#---------------------------------------------------------------------------
# This script starts/stops the following
# rpc.statd if necessary (also checked by init.d/nfsmount)
# rpd.rquotad
# rpd.nfsd
# rpc.mountd
#
# (17 Aug 2001 agriffis)
#---------------------------------------------------------------------------
# These can be overridden in /etc/rc.d/config/basic if desired
RPCNFSDCOUNT=8 # Number of servers to be started up by default
RPCMOUNTDOPTS=
. /etc/rc.d/config/functions
. /etc/rc.d/config/basic
# This variable is used for controlling whether or not to run exportfs -ua;
# see stop() for more information
RESTARTING=no
opts="start stop restart reload"
start_statd() {
# Don't start rpc.statd if already started by init.d/nfsmount
killall -0 rpc.statd &>/dev/null && return 0
ebegin "Starting NFS statd"
start-stop-daemon --start --quiet --exec /sbin/rpc.statd 1>&2
eend $? "Error starting NFS statd"
}
stop_statd() {
# Don't stop rpc.statd if it's in use by init.d/nfsmount.
mount -t nfs | grep -q . && return 0
# Make sure it's actually running
killall -0 rpc.statd &>/dev/null || return 0
# Okay, all tests passed, stop rpc.statd
ebegin "Stopping NFS statd"
start-stop-daemon --stop --quiet --exec /sbin/rpc.statd 1>&2
eend $? "Error stopping NFS statd"
}
start() {
if [ "$NFSSERVER" = "yes" ]
then
start_statd
if grep -q '^/' /etc/exports &>/dev/null; then
ebegin "Exporting NFS directories"
/sbin/exportfs -r 1>&2
eend $? "Error exporting NFS directories"
fi
ebegin "Starting NFS rquotad"
start-stop-daemon --start --quiet --exec /sbin/rpc.rquotad 1>&2
eend $? "Error starting NFS rquotad"
ebegin "Starting NFS daemon"
start-stop-daemon --start --quiet --exec \
/sbin/rpc.nfsd -- $RPCNFSDCOUNT 1>&2
eend $? "Error starting NFS daemon"
# Check if we support NFSv3
ebegin "Starting NFS mountd"
rpcinfo -u localhost nfs 3 &>/dev/null || \
RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
start-stop-daemon --start --quiet --exec \
/sbin/rpc.mountd -- $RPCMOUNTDOPTS 1>&2
eend $? "Error starting NFS mountd"
fi
}
stop() {
# Don't check NFSSERVER variable since it might have changed,
# instead use --oknodo to smooth things over
ebegin "Stopping NFS mountd"
start-stop-daemon --stop --quiet --oknodo \
--exec /sbin/rpc.mountd 1>&2
eend $? "Error stopping NFS mountd"
ebegin "Stopping NFS daemon"
start-stop-daemon --stop --quiet --oknodo \
--name nfsd --user root --signal 2 1>&2
eend $? "Error stopping NFS daemon"
ebegin "Stopping NFS rquotad"
start-stop-daemon --stop --quiet --oknodo \
--exec /sbin/rpc.rquotad 1>&2
eend $? "Error stopping NFS rquotad"
# When simply restarting the NFS server, running "exportfs -ua"
# probably isn't what the user wants. Running it causes all
# entries listed in xtab to be removed from the kernel export
# tables, and the xtab file is cleared. This effectively shuts
# down all NFS activity, leaving all clients holding stale NFS
# filehandles, /even/ when the NFS server has restarted.
#
# This is what you would want if you were shutting down the NFS
# server for good, or for a long period of time, but not when the
# NFS server will be running again in short order. In this case,
# then "exportfs -r" will reread the xtab, and all the current
# clients will be able to resume NFS activity, /without/ needing
# to umount/(re)mount the filesystem.
if [ "$RESTARTING" = no ]; then
ebegin "Unexporting NFS directories"
/sbin/exportfs -ua 1>&2
eend $? "Error unexporting NFS directories"
fi
stop_statd
}
reload() {
/sbin/exportfs -r
}
restart() {
# See comment in stop() regarding exportfs -ua
RESTARTING=yes
stop
start
}
doservice "${@}"
|