]>
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) | |
d419f9f1 | 39 | # Start daemons. |
05bf5368 | 40 | if [ "$NFSDTYPE" = "U" ] ; then |
bf36188d | 41 | msg_starting "NFS mountd" |
0e3733a2 | 42 | daemon rpc.mountd |
bf36188d | 43 | msg_starting "NFS daemon" |
0e3733a2 | 44 | daemon rpc.nfsd |
45 | else | |
bf36188d | 46 | msg_starting "NFS" |
d419f9f1 | 47 | daemon /usr/sbin/exportfs -r |
bf36188d | 48 | msg_starting "NFS mountd" |
d419f9f1 | 49 | daemon rpc.mountd $RPCMOUNTDOPTS |
bf36188d | 50 | msg_starting "NFS daemon" |
d419f9f1 | 51 | daemon rpc.nfsd $RPCNFSDCOUNT |
0e3733a2 | 52 | fi |
083dbab7 | 53 | touch /var/lock/subsys/nfs |
54 | ;; | |
55 | stop) | |
56 | # Stop daemons. | |
05bf5368 | 57 | if [ "$NFSDTYPE" = "U" ] ; then |
bf36188d | 58 | msg_stopping "NFS mountd" |
d419f9f1 | 59 | killproc rpc.mountd |
bf36188d | 60 | msg_stopping "NFS daemon" |
d419f9f1 JR |
61 | killproc rpc.nfsd |
62 | else | |
bf36188d | 63 | msg_stopping "NFS mountd" |
d419f9f1 | 64 | killproc rpc.mountd |
bf36188d | 65 | msg_stopping "NFS daemon" |
d419f9f1 | 66 | killproc nfsd -QUIT |
bf36188d | 67 | msg_stopping "NFS" |
6089d708 | 68 | daemon /usr/sbin/exportfs -au |
d419f9f1 | 69 | fi |
083dbab7 | 70 | rm -f /var/lock/subsys/nfs |
71 | ;; | |
72 | status) | |
73 | status rpc.mountd | |
05bf5368 | 74 | if [ "$NFSDTYPE" = "U" ] ; then |
d419f9f1 JR |
75 | status rpc.nfsd |
76 | else | |
77 | status nfsd | |
78 | fi | |
083dbab7 | 79 | ;; |
80 | restart) | |
05bf5368 | 81 | if [ "$NFSDTYPE" = "U" ] ; then |
d419f9f1 JR |
82 | $0 stop |
83 | $0 start | |
84 | else | |
85 | show "Restarting NFS services (killing)" | |
86 | killproc rpc.mountd | |
87 | show "Restarting NFS services (starting)" | |
88 | daemon rpc.mountd $RPCMOUNTDOPTS | |
89 | /usr/sbin/exportfs -r | |
90 | touch /var/lock/subsys/nfs | |
91 | fi | |
92 | ;; | |
93 | reload) | |
05bf5368 | 94 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 JR |
95 | /usr/sbin/exportfs |
96 | touch /var/lock/subsys/nfs | |
97 | ;; | |
98 | probe) | |
05bf5368 | 99 | [ "$NFSDTYPE" = "U" ] && exit 0 |
d419f9f1 JR |
100 | if [ ! -f /var/lock/subsys/nfs ] ; then |
101 | echo start; exit 0 | |
102 | fi | |
103 | /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?" | |
104 | /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?" | |
105 | if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then | |
106 | echo restart; exit 0 | |
107 | fi | |
108 | if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then | |
109 | echo reload; exit 0 | |
110 | fi | |
083dbab7 | 111 | ;; |
112 | *) | |
bf36188d | 113 | msg_Usage "$0 {start|stop|status|restart|reload|probe}" |
083dbab7 | 114 | exit 1 |
115 | esac | |
116 | ||
117 | exit 0 |