]>
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. |
7bf93ef0 | 22 | if [ "${NETWORKING}" = "no" ]; then |
d419f9f1 | 23 | echo "WARNING: Networking is down. Knfsd can't be run" |
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 JR |
39 | # Start daemons. |
40 | if [ NFSDTYPE = "U" ] ; then | |
41 | show "Starting NFS mountd" | |
0e3733a2 | 42 | daemon rpc.mountd |
d419f9f1 | 43 | show "Starting NFS daemon" |
0e3733a2 | 44 | daemon rpc.nfsd |
45 | else | |
d419f9f1 JR |
46 | show "Starting NFS services" |
47 | daemon /usr/sbin/exportfs -r | |
48 | show "Starting NFS mountd" | |
49 | daemon rpc.mountd $RPCMOUNTDOPTS | |
50 | show "Starting NFS daemon" | |
51 | daemon rpc.nfsd $RPCNFSDCOUNT | |
0e3733a2 | 52 | fi |
083dbab7 | 53 | touch /var/lock/subsys/nfs |
54 | ;; | |
55 | stop) | |
56 | # Stop daemons. | |
d419f9f1 JR |
57 | if [ NFSDTYPE = "U" ] ; then |
58 | show "Shutting down NFS mountd" | |
59 | killproc rpc.mountd | |
60 | show "Shutting down NFS daemon" | |
61 | killproc rpc.nfsd | |
62 | else | |
63 | show "Shutting down NFS services" | |
64 | daemon /usr/sbin/exportfs -au | |
65 | show "Shutting down NFS mountd" | |
66 | killproc rpc.mountd | |
67 | show "Shutting down NFS daemon" | |
68 | killproc nfsd -QUIT | |
69 | fi | |
083dbab7 | 70 | rm -f /var/lock/subsys/nfs |
71 | ;; | |
72 | status) | |
73 | status rpc.mountd | |
d419f9f1 JR |
74 | if [ NFSDTYPE = "U" ] ; then |
75 | status rpc.nfsd | |
76 | else | |
77 | status nfsd | |
78 | fi | |
083dbab7 | 79 | ;; |
80 | restart) | |
d419f9f1 JR |
81 | if [ NFSDTYPE = "U" ] ; then |
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) | |
94 | [ NFSDTYPE = "U" ] && exit 0 | |
95 | /usr/sbin/exportfs | |
96 | touch /var/lock/subsys/nfs | |
97 | ;; | |
98 | probe) | |
99 | [ NFSDTYPE = "U" ] && exit 0 | |
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 | *) | |
d419f9f1 | 113 | echo "Usage: nfs {start|stop|status|restart|reload}" |
083dbab7 | 114 | exit 1 |
115 | esac | |
116 | ||
117 | exit 0 |