]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/nodist/nfs-client
Initial script for nfs client (lockd/statd)
[nfs-utils.git] / etc / nodist / nfs-client
1 #!/bin/sh
2 # nfs   This shell script starts and stops the nfs services in a distribution
3 #       independent fashion.
4 ## description:  starts and stops nfs client services
5 # chkconfig: 2345 99 01
6 #
7 # Copyright (c) 2000-2001 Mission Critical Linux, Inc.
8 #
9
10 PATH=/sbin:/bin:/usr/sbin:/usr/bin
11 export PATH
12
13 # Who am I?
14 SCRIPT_NAME=`basename $0`
15
16 # Grab our daemon functions.
17 . `dirname $0`/nfs-functions
18
19 # Kernel daemons and options
20 PREFIX="rpc."           # Prefix for kernel execs (usually "rpc.")
21 LOCKD="lockd"           # Lockd
22
23 # User daemons and options
24 STATD="rpc.statd"       # NLM Server
25
26
27 # We need rpc.lockd on kernels < 2.2.18 if Trond Myklebust and Dave Higgens'
28 # NFS patches have not been applied.
29 lockd_not_needed()
30 {
31     if [ "`uname`" = "Linux" ]; then 
32
33         os_rel=`uname -r`
34
35         # This messily chops up the linux version number and turns it into
36         # a comparable integer.
37         # 
38         # printf  value                         description
39         # %d      `echo $os_rel | cut -f1 -d.`  Major Linux release #
40         # %02d    `echo $os_rel | cut -f2 -d.`  Minor Linux release #
41         # %02d    `echo $os_rel | cut -f3 -d.`  Patchlevel
42         #
43         linux_version_code=`printf "%d%02d%02d" \`echo $os_rel | cut -f1 -d.\` \`echo $os_rel | cut -f2 -d.\` \`echo $os_rel | cut -f3 -d.\``
44         return $((linux_version_code < 20218))
45     fi
46
47     # On non-Linux systems, assume that lockd is always required.
48     return 1
49 }
50
51 # We use "type -path" instead of "which" since it's internal to bash.
52 [ -x "`type -path $STATD`" ] || exit 0
53
54 # Check to see if we need lockd (ie, nfsd doesn't handle spawning and
55 # maintaining it)
56 if lockd_not_needed
57 then
58     unset LOCKD
59 else
60     # We need it.  Make sure we have it.
61     [ -x "`type -path $PREFIX$LOCKD`" ] || exit 0
62 fi
63
64 # Handle how we were called.
65 case "$1" in
66 start)
67     # Start rpc.statd daemon without options...
68     echo -n "Starting $STATD: "
69     startdaemon $STATD
70
71     if [ -n "$LOCKD" ]
72     then
73         echo -n "Starting $LOCKD: "
74         startdaemon $PREFIX$LOCKD
75     fi
76
77     # if this lock file doesn't exist, init won't even try to run
78     # the shutdown script for this service on RedHat systems!
79     # on non-RedHat systems, /var/lock/subsys may not exist.
80     touch /var/lock/subsys/$SCRIPT_NAME &> /dev/null
81     ;;
82
83 stop)
84     echo -n "Stopping $STATD: "
85     stopdaemon $STATD
86
87     if [ -n "$LOCKD" ]; then 
88         echo -n "Stopping $LOCKD: "
89         stopdaemon $LOCKD
90     fi
91
92     rm -f /var/lock/subsys/$SCRIPT_NAME 
93     ;;
94
95 restart)
96     $0 stop
97     $0 start
98     ;;
99
100 status)
101     daemonstatus $STATD
102
103     if [ -n "$LOCKD" ]; then
104         daemonstatus $LOCKD
105     fi
106
107     exit 0
108     ;;
109
110 *)
111     echo "Usage: $0 {start|stop|status|restart}"
112     exit 1
113 esac
114
115 exit 0