Initial commit: Uploaded everything from abs/core
[arch-rock.git] / support / nfs-utils / nfsd
blobce891e245d3f1731e1a5cb6464c346c086a779de
1 #!/bin/bash
3 # source application-specific settings
4 [ -f /etc/conf.d/nfs ] && . /etc/conf.d/nfs
6 . /etc/rc.conf
7 . /etc/rc.d/functions
9 DAEMON_NAME=nfsd
10 NFSD_PID=`pidof -o %PPID nfsd`
11 MOUNTD_PID=`pidof -o %PPID /usr/sbin/rpc.mountd`
12 case "$1" in
13 start)
14 stat_busy "Starting $DAEMON_NAME"
15 # Check for portmap
16 if [ ! -f /var/run/daemons/portmap ]; then
17 echo "ERROR: portmap is not running"
18 stat_fail
19 exit 1
21 # Check for nfslock
22 if [ ! -f /var/run/daemons/nfslock ]; then
23 echo "ERROR: nfslock is not running"
24 stat_fail
25 exit 1
27 # Check for /proc/fs/nfsd
28 if grep -qs nfsd /proc/filesystems ; then
29 if ! grep -qs "nfsd /proc/fs/nfsd" /proc/mounts ; then
30 mount -t nfsd -o nodev,noexec,nosuid nfsd /proc/fs/nfsd
33 # Run exportfs
34 /usr/sbin/exportfs -r
35 # Run mountd
36 [ -z "$MOUNTD_PID" ] && /usr/sbin/rpc.mountd $MOUNTD_OPTS
37 if [ $? -gt 0 ]; then
38 stat_fail
39 exit 1
40 else
41 echo `pidof -o %PPID /usr/sbin/rpc.mountd` > /var/run/rpc.mountd.pid
43 # Run nfsd
44 [ -z "$NFSD_PID" ] && /usr/sbin/rpc.nfsd $NFSD_OPTS
45 if [ $? -gt 0 ]; then
46 stat_fail
47 exit 1
48 else
49 echo `pidof -o %PPID nfsd` > /var/run/rpc.nfsd.pid
51 # Run sm-notify
52 /usr/sbin/sm-notify $SMNOTIFY_OPTS
53 add_daemon $DAEMON_NAME
54 stat_done
57 stop)
58 stat_busy "Stopping $DAEMON_NAME"
59 [ ! -z "$MOUNTD_PID" ] && kill $MOUNTD_PID &> /dev/null
60 if [ $? -gt 0 ]; then
61 stat_fail
62 exit 1
63 else
64 rm /var/run/rpc.mountd.pid &> /dev/null
66 sleep 1
67 [ ! -z "$NFSD_PID" ] && kill $NFSD_PID &> /dev/null
68 if [ $? -gt 0 ]; then
69 stat_fail
70 exit 1
71 else
72 kill -9 $NFSD_PID &> /dev/null
73 rm /var/run/rpc.nfsd.pid &> /dev/null
75 if [ "$RUNLEVEL" = "0" ]; then
76 /usr/sbin/exportfs -au
78 rm_daemon $DAEMON_NAME
79 stat_done
82 restart)
83 $0 stop
84 sleep 2
85 $0 start
89 echo "usage: $0 {start|stop|restart}"
90 esac
91 exit 0