]> git.pld-linux.org Git - packages/nfs-utils.git/blob - nfslock.init
- consistent messages
[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 82
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 statd"
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                 # Don't put sm-notify here, statd will run it when started
54                 msg_starting "NFS statd"
55                 daemon rpc.statd $STATDOPTS
56                 RETVAL=$?
57                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
58         else
59                 msg_already_running "NFS statd"
60         fi
61 }
62
63 stop() {
64         if [ -f /var/lock/subsys/nfslock ]; then
65                 # Reset the lockd ports if they were set
66                 if [ -n "$LOCKD_TCPPORT" ]; then
67                         /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
68                 fi
69                 if [ -n "$LOCKD_UDPPORT" ]; then
70                         /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
71                 fi
72                 # Stop daemons.
73                 msg_stopping "NFS statd"
74                 killproc rpc.statd
75                 rm -f /var/lock/subsys/nfslock
76         else
77                 msg_not_running "NFS statd"
78         fi
79 }
80
81 RETVAL=0
82 # See how we were called.
83 case "$1" in
84   start)
85         start
86         ;;
87   stop)
88         stop
89         ;;
90   status)
91         status rpc.statd
92         exit $?
93         ;;
94   restart|force-reload)
95         stop
96         start
97         ;;
98   probe)
99         if [ ! -f /var/lock/subsys/nfslock ]; then
100                 echo start
101                 exit 0
102         fi
103         /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
104         if [ $STATD = 1 ]; then
105                 echo restart
106                 exit 0
107         fi
108         ;;
109   *)
110         msg_usage "$0 {start|stop|restart|force-reload|probe|status}"
111         exit 3
112 esac
113
114 exit $RETVAL
This page took 0.034797 seconds and 3 git commands to generate.