]> git.pld-linux.org Git - packages/nfs-utils.git/blame - nfs.init
- small fixes
[packages/nfs-utils.git] / nfs.init
CommitLineData
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 22if [ "${NETWORKING}" = "no" ]; then
d419f9f1 23 echo "WARNING: Networking is down. Knfsd can't be run"
7bf93ef0 24 exit 1
25fi
083dbab7 26
d419f9f1
JR
27if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
28 [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && exit 0
29fi
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.
37case "$1" in
38 start)
d419f9f1 39 # Start daemons.
05bf5368 40 if [ "$NFSDTYPE" = "U" ] ; then
d419f9f1 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.
05bf5368 57 if [ "$NFSDTYPE" = "U" ] ; then
d419f9f1
JR
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
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 *)
05bf5368 113 echo "Usage: nfs {start|stop|status|restart|reload|probe}"
083dbab7 114 exit 1
115esac
116
117exit 0
This page took 0.044067 seconds and 4 git commands to generate.