]>
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. |
bf36188d JR |
22 | if is_no "${NETWORKING}"; then |
23 | msg_Network_Down NFSD | |
7bf93ef0 | 24 | exit 1 |
25 | fi | |
083dbab7 | 26 | |
d419f9f1 JR |
27 | if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then |
28 | [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && exit 0 | |
29 | fi | |
083dbab7 | 30 | |
d419f9f1 JR |
31 | # Sanity checks |
32 | [ -x /usr/sbin/rpc.nfsd ] || exit 0 | |
33 | [ -x /usr/sbin/rpc.mountd ] || exit 0 | |
34 | [ -f /etc/exports ] || exit 0 | |
0e3733a2 | 35 | |
083dbab7 | 36 | # See how we were called. |
37 | case "$1" in | |
38 | start) | |
0fb1eec5 JB |
39 | # Check if the service is already running? |
40 | if [ ! -f /var/lock/subsys/nfs ]; then | |
41 | # Start daemons. | |
42 | if [ "$NFSDTYPE" = "U" ] ; then | |
43 | msg_starting "NFS mountd" | |
44 | daemon rpc.mountd | |
45 | msg_starting "NFS daemon" | |
46 | daemon rpc.nfsd | |
47 | else | |
48 | msg_starting "NFS" | |
49 | daemon /usr/sbin/exportfs -r | |
50 | msg_starting "NFS mountd" | |
51 | daemon rpc.mountd $RPCMOUNTDOPTS | |
52 | msg_starting "NFS daemon" | |
53 | daemon rpc.nfsd $RPCNFSDCOUNT | |
54 | fi | |
55 | touch /var/lock/subsys/nfs | |
0e3733a2 | 56 | else |
0fb1eec5 JB |
57 | msg_Already_Running "NFS" |
58 | exit 1 | |
0e3733a2 | 59 | fi |
083dbab7 | 60 | ;; |
61 | stop) | |
0fb1eec5 JB |
62 | if [ -f /var/lock/subsys/nfs ]; then |
63 | # Stop daemons. | |
64 | if [ "$NFSDTYPE" = "U" ] ; then | |
65 | msg_stopping "NFS mountd" | |
66 | killproc rpc.mountd | |
67 | msg_stopping "NFS daemon" | |
68 | killproc rpc.nfsd | |
69 | else | |
70 | msg_stopping "NFS mountd" | |
71 | killproc rpc.mountd | |
72 | msg_stopping "NFS daemon" | |
73 | killproc nfsd -QUIT | |
74 | msg_stopping "NFS" | |
75 | daemon /usr/sbin/exportfs -au | |
76 | fi | |
77 | rm -f /var/lock/subsys/nfs | |
d419f9f1 | 78 | else |
0fb1eec5 JB |
79 | msg_Not_Running "NFS" |
80 | exit 1 | |
d419f9f1 | 81 | fi |
083dbab7 | 82 | ;; |
83 | status) | |
84 | status rpc.mountd | |
05bf5368 | 85 | if [ "$NFSDTYPE" = "U" ] ; then |
d419f9f1 JR |
86 | status rpc.nfsd |
87 | else | |
88 | status nfsd | |
89 | fi | |
083dbab7 | 90 | ;; |
91 | restart) | |
05bf5368 | 92 | if [ "$NFSDTYPE" = "U" ] ; then |
d419f9f1 JR |
93 | $0 stop |
94 | $0 start | |
95 | else | |
96 | show "Restarting NFS services (killing)" | |
97 | killproc rpc.mountd | |
98 | show "Restarting NFS services (starting)" | |
99 | daemon rpc.mountd $RPCMOUNTDOPTS | |
100 | /usr/sbin/exportfs -r | |
101 | touch /var/lock/subsys/nfs | |
102 | fi | |
103 | ;; | |
104 | reload) | |
05bf5368 | 105 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 JR |
106 | /usr/sbin/exportfs |
107 | touch /var/lock/subsys/nfs | |
108 | ;; | |
109 | probe) | |
05bf5368 | 110 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 JR |
111 | if [ ! -f /var/lock/subsys/nfs ] ; then |
112 | echo start; exit 0 | |
113 | fi | |
114 | /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?" | |
115 | /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?" | |
116 | if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then | |
117 | echo restart; exit 0 | |
118 | fi | |
119 | if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then | |
120 | echo reload; exit 0 | |
121 | fi | |
083dbab7 | 122 | ;; |
123 | *) | |
bf36188d | 124 | msg_Usage "$0 {start|stop|status|restart|reload|probe}" |
083dbab7 | 125 | exit 1 |
126 | esac | |
127 | ||
128 | exit 0 |