4afee558be0109b48e5b89dc9035d2f19f0069c6
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / nfs-utils / S60nfs
1 #!/bin/sh
2 #
3 # nfs           This shell script takes care of starting and stopping
4 #               the NFS services. Stolen from RedHat FC5.
5
6 [ -x /usr/sbin/rpc.statd ] || exit 0
7 [ -x /usr/sbin/rpc.nfsd ] || exit 0
8 [ -x /usr/sbin/rpc.mountd ] || exit 0
9 [ -x /usr/sbin/exportfs ] || exit 0
10
11 # Don't fail if /etc/exports doesn't exist; create a bare-bones version and continue.
12 [ -r /etc/exports ] || \
13     { touch /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
14     { echo "/etc/exports does not exist" ; exit 0 ; }
15     
16 # The /var/lib/nfs directory is actually on a tmpfs filesystem.
17 mkdir -p /var/lib/nfs/sm
18 mkdir -p /var/lib/nfs/sm.bak
19 mkdir -p /var/lock/subsys
20 touch /var/lib/nfs/etab
21 touch /var/lib/nfs/rmtab
22 touch /var/lib/nfs/state
23 touch /var/lib/nfs/xtab
24
25 start() {
26         # Start daemons.
27         echo -n "Starting NFS statd: "
28         rpc.statd
29         touch /var/lock/subsys/nfslock
30         echo "done"
31
32         echo -n "Starting NFS services: "
33         /usr/sbin/exportfs -r
34         rpc.statd
35         echo "done"
36
37         echo -n "Starting NFS daemon: "
38         rpc.nfsd 2
39         echo "done"
40
41         echo -n "Starting NFS mountd: "
42         rpc.mountd
43         echo "done"
44         touch /var/lock/subsys/nfs
45 }
46
47 stop() {
48         # Stop daemons.
49         echo -n "Shutting down NFS mountd: "
50         killall -q rpc.mountd
51         echo "done"
52
53         echo "Shutting down NFS daemon: "
54         kill -9 `pidof nfsd` 2>/dev/null
55         echo "done"
56
57         echo -n "Shutting down NFS services: "
58         /usr/sbin/exportfs -au
59         rm -f /var/lock/subsys/nfs
60         killall -q rpc.statd
61         echo "done"
62
63         echo -n "Stopping NFS statd: "
64         killall -q rpc.statd
65         echo "done"
66         rm -f /var/lock/subsys/nfslock
67 }
68
69 # See how we were called.
70 case "$1" in
71   start)
72         start
73         ;;
74   stop)
75         stop
76         ;;
77   restart)
78         stop
79         start
80         ;;
81   reload)
82         /usr/sbin/exportfs -r
83         touch /var/lock/subsys/nfs
84         ;;
85   *)
86         echo "Usage: nfs {start|stop|reload}"
87         exit 1
88 esac
89
90 exit 0