]>
Commit | Line | Data |
---|---|---|
bf44c74c | 1 | #!/bin/sh |
083dbab7 | 2 | # |
d419f9f1 JR |
3 | # nfs This shell script takes care of starting and stopping |
4 | # the NFS services. | |
083dbab7 | 5 | # |
0e3733a2 | 6 | # chkconfig: 345 60 20 |
7 | # description: NFS is a popular protocol for file sharing across TCP/IP \ | |
8 | # networks. This service provides NFS server functionality, \ | |
9 | # which is configured via the /etc/exports file. | |
10 | # probe: true | |
083dbab7 | 11 | |
0e3733a2 | 12 | # Source function library |
083dbab7 | 13 | . /etc/rc.d/init.d/functions |
14 | ||
0e3733a2 | 15 | # Get network config |
083dbab7 | 16 | . /etc/sysconfig/network |
17 | ||
0e3733a2 | 18 | # Get service config |
d419f9f1 | 19 | [ -f /etc/sysconfig/nfsd ] && . /etc/sysconfig/nfsd |
0e3733a2 | 20 | |
083dbab7 | 21 | # Check that networking is up. |
ff100ffc | 22 | if is_yes "${NETWORKING}"; then |
23 | if [ ! -f /var/lock/subsys/network ]; then | |
24 | msg_network_down NFSD | |
25 | exit 1 | |
26 | fi | |
27 | else | |
28 | exit 0 | |
7bf93ef0 | 29 | fi |
083dbab7 | 30 | |
d419f9f1 | 31 | if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then |
ff100ffc | 32 | [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0 |
d419f9f1 | 33 | fi |
083dbab7 | 34 | |
d419f9f1 JR |
35 | # Sanity checks |
36 | [ -x /usr/sbin/rpc.nfsd ] || exit 0 | |
37 | [ -x /usr/sbin/rpc.mountd ] || exit 0 | |
38 | [ -f /etc/exports ] || exit 0 | |
0e3733a2 | 39 | |
083dbab7 | 40 | # See how we were called. |
41 | case "$1" in | |
42 | start) | |
0fb1eec5 JB |
43 | # Check if the service is already running? |
44 | if [ ! -f /var/lock/subsys/nfs ]; then | |
45 | # Start daemons. | |
ff100ffc | 46 | if [ "$NFSDTYPE" = "U" ] ; then |
0fb1eec5 JB |
47 | msg_starting "NFS mountd" |
48 | daemon rpc.mountd | |
49 | msg_starting "NFS daemon" | |
50 | daemon rpc.nfsd | |
51 | else | |
52 | msg_starting "NFS" | |
53 | daemon /usr/sbin/exportfs -r | |
54 | msg_starting "NFS mountd" | |
55 | daemon rpc.mountd $RPCMOUNTDOPTS | |
56 | msg_starting "NFS daemon" | |
57 | daemon rpc.nfsd $RPCNFSDCOUNT | |
58 | fi | |
59 | touch /var/lock/subsys/nfs | |
0e3733a2 | 60 | else |
ff100ffc | 61 | msg_already_running "NFS" |
0fb1eec5 | 62 | exit 1 |
0e3733a2 | 63 | fi |
083dbab7 | 64 | ;; |
65 | stop) | |
0fb1eec5 JB |
66 | if [ -f /var/lock/subsys/nfs ]; then |
67 | # Stop daemons. | |
ff100ffc | 68 | if [ "$NFSDTYPE" = "U" ] ; then |
0fb1eec5 JB |
69 | msg_stopping "NFS mountd" |
70 | killproc rpc.mountd | |
71 | msg_stopping "NFS daemon" | |
72 | killproc rpc.nfsd | |
73 | else | |
74 | msg_stopping "NFS mountd" | |
75 | killproc rpc.mountd | |
76 | msg_stopping "NFS daemon" | |
77 | killproc nfsd -QUIT | |
78 | msg_stopping "NFS" | |
79 | daemon /usr/sbin/exportfs -au | |
80 | fi | |
81 | rm -f /var/lock/subsys/nfs | |
d419f9f1 | 82 | else |
ff100ffc | 83 | msg_not_running "NFS" |
0fb1eec5 | 84 | exit 1 |
d419f9f1 | 85 | fi |
083dbab7 | 86 | ;; |
87 | status) | |
88 | status rpc.mountd | |
ff100ffc | 89 | if [ "$NFSDTYPE" = "U" ] ; then |
d419f9f1 JR |
90 | status rpc.nfsd |
91 | else | |
92 | status nfsd | |
93 | fi | |
083dbab7 | 94 | ;; |
95 | restart) | |
232f9b6a | 96 | $0 stop |
97 | $0 start | |
d419f9f1 JR |
98 | ;; |
99 | reload) | |
05bf5368 | 100 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 JR |
101 | /usr/sbin/exportfs |
102 | touch /var/lock/subsys/nfs | |
103 | ;; | |
104 | probe) | |
05bf5368 | 105 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 | 106 | if [ ! -f /var/lock/subsys/nfs ] ; then |
ff100ffc | 107 | echo start |
108 | exit 0 | |
d419f9f1 JR |
109 | fi |
110 | /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?" | |
111 | /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?" | |
112 | if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then | |
ff100ffc | 113 | echo restart |
114 | exit 0 | |
d419f9f1 JR |
115 | fi |
116 | if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then | |
ff100ffc | 117 | echo reload |
118 | exit 0 | |
d419f9f1 | 119 | fi |
083dbab7 | 120 | ;; |
121 | *) | |
0a59f582 | 122 | msg_usage "$0 {start|stop|status|restart|reload|probe}" |
083dbab7 | 123 | exit 1 |
124 | esac | |
125 | ||
126 | exit 0 |