]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfslock.init
- started update to 1.1.0-rc1
[packages/nfs-utils.git] / nfslock.init
1 #!/bin/sh
2 #
3 # nfslock       This shell script takes care of starting and stopping
4 #               the NFS file locking service.
5 #
6 # chkconfig:    345 14 81
7 # description:  NFS is a popular protocol for file sharing across \
8 #               TCP/IP networks. This service provides NFS file \
9 #               locking functionality.
10 # probe:        true
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Get service config
19 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
20
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24                 msg_network_down "NFS lockd"
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
32         [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
33 fi
34
35 # /usr may be on NFS, fail silently, nfsfs will start it
36 [ -x /usr/sbin/rpc.statd ] || exit 0
37
38 start() {
39         # Check if the service is already running?
40         if [ ! -f /var/lock/subsys/nfslock ]; then
41                 # Set the ports lockd should listen on
42                 if [ -n "$LOCKD_TCPPORT" ]; then
43                         /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
44                 fi
45                 if [ -n "$LOCKD_UDPPORT" ]; then
46                         /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
47                 fi
48
49                 [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT"
50                 [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT"
51
52                 # Start daemons.
53                 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
54                         msg_starting "NFS statd"
55                         daemon rpc.statd $STATDOPTS
56                         RETVAL=$?
57                         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
58                 else
59                         touch /var/lock/subsys/nfslock
60                 fi
61         else
62                 msg_already_running "NFS statd"
63         fi
64 }
65
66 stop() {
67         if [ -f /var/lock/subsys/nfslock ]; then
68                 # Reset the lockd ports if they were set
69                 if [ -n "$LOCKD_TCPPORT" ]; then
70                         /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
71                 fi
72                 if [ -n "$LOCKD_UDPPORT" ]; then
73                         /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
74                 fi
75                 # Stop daemons.
76                 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
77                         msg_stopping "NFS statd"
78                         killproc rpc.statd
79                 fi
80                 rm -f /var/lock/subsys/nfslock
81         else
82                 msg_not_running "NFS statd"
83         fi
84 }
85
86 RETVAL=0
87 # See how we were called.
88 case "$1" in
89   start)
90         start
91         ;;
92   stop)
93         stop
94         ;;
95   status)
96         if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
97                 status rpc.statd
98                 exit $?
99         else
100                 echo "NFSv2 and NFSv3 disabled"
101                 exit 0
102         fi
103         ;;
104   restart|force-reload)
105         stop
106         start
107         ;;
108   probe)
109         if [ ! -f /var/lock/subsys/nfslock ]; then
110                 echo start
111                 exit 0
112         fi
113         if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
114                 /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
115                 if [ $STATD = 1 ]; then
116                         echo restart
117                         exit 0
118                 fi
119         else
120                 exit 0
121         fi
122         ;;
123   *)
124         msg_usage "$0 {start|stop|restart|force-reload|probe|status}"
125         exit 3
126 esac
127
128 exit $RETVAL
This page took 0.167592 seconds and 3 git commands to generate.