diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver | |
download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver')
-rw-r--r-- | meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver new file mode 100644 index 0000000000..6e0df7e2ea --- /dev/null +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver | |||
@@ -0,0 +1,129 @@ | |||
1 | #!/bin/sh | ||
2 | ### BEGIN INIT INFO | ||
3 | # Provides: nfs-kernel-server | ||
4 | # Required-Start: $remote_fs nfs-common $portmap hwclock | ||
5 | # Required-Stop: $remote_fs nfs-common $portmap hwclock | ||
6 | # Default-Start: 2 3 4 5 | ||
7 | # Default-Stop: 0 1 6 | ||
8 | # Short-Description: Kernel NFS server support | ||
9 | # Description: NFS is a popular protocol for file sharing across | ||
10 | # TCP/IP networks. This service provides NFS server | ||
11 | # functionality, which is configured via the | ||
12 | # /etc/exports file. | ||
13 | ### END INIT INFO | ||
14 | # | ||
15 | # Startup script for nfs-utils | ||
16 | # | ||
17 | # Source function library. | ||
18 | . /etc/init.d/functions | ||
19 | # | ||
20 | # The environment variable NFS_SERVERS may be set in /etc/default/nfsd | ||
21 | # Other control variables may be overridden here too | ||
22 | test -r /etc/default/nfsd && . /etc/default/nfsd | ||
23 | # | ||
24 | # Location of executables: | ||
25 | test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd | ||
26 | test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd | ||
27 | # | ||
28 | # The user mode program must also exist (it just starts the kernel | ||
29 | # threads using the kernel module code). | ||
30 | test -x "$NFS_MOUNTD" || exit 0 | ||
31 | test -x "$NFS_NFSD" || exit 0 | ||
32 | # | ||
33 | # Default is 8 threads, value is settable between 1 and the truely | ||
34 | # ridiculous 99 | ||
35 | test "$NFS_SERVERS" != "" && test "$NFS_SERVERS" -gt 0 && test "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8 | ||
36 | # | ||
37 | #---------------------------------------------------------------------- | ||
38 | # Startup and shutdown functions. | ||
39 | # Actual startup/shutdown is at the end of this file. | ||
40 | #mountd | ||
41 | start_mountd(){ | ||
42 | echo -n 'starting mountd: ' | ||
43 | start-stop-daemon --start --exec "$NFS_MOUNTD" -- "-f /etc/exports $@" | ||
44 | echo done | ||
45 | } | ||
46 | stop_mountd(){ | ||
47 | echo -n 'stopping mountd: ' | ||
48 | start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD" | ||
49 | echo done | ||
50 | } | ||
51 | # | ||
52 | #nfsd | ||
53 | start_nfsd(){ | ||
54 | modprobe -q nfsd | ||
55 | grep -q nfsd /proc/filesystems || { | ||
56 | echo NFS daemon support not enabled in kernel | ||
57 | exit 1 | ||
58 | } | ||
59 | grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd | ||
60 | grep -q nfsd /proc/mounts || { | ||
61 | echo nfsd filesystem could not be mounted at /proc/fs/nfsd | ||
62 | exit 1 | ||
63 | } | ||
64 | |||
65 | echo -n "starting $1 nfsd kernel threads: " | ||
66 | start-stop-daemon --start --exec "$NFS_NFSD" -- "$@" | ||
67 | echo done | ||
68 | } | ||
69 | delay_nfsd(){ | ||
70 | for delay in 0 1 2 3 4 5 6 7 8 9 | ||
71 | do | ||
72 | if pidof nfsd >/dev/null | ||
73 | then | ||
74 | echo -n . | ||
75 | sleep 1 | ||
76 | else | ||
77 | return 0 | ||
78 | fi | ||
79 | done | ||
80 | return 1 | ||
81 | } | ||
82 | stop_nfsd(){ | ||
83 | # WARNING: this kills any process with the executable | ||
84 | # name 'nfsd'. | ||
85 | echo -n 'stopping nfsd: ' | ||
86 | start-stop-daemon --stop --quiet --signal 1 --name nfsd | ||
87 | if delay_nfsd || { | ||
88 | echo failed | ||
89 | echo ' using signal 9: ' | ||
90 | start-stop-daemon --stop --quiet --signal 9 --name nfsd | ||
91 | delay_nfsd | ||
92 | } | ||
93 | then | ||
94 | echo done | ||
95 | else | ||
96 | echo failed | ||
97 | fi | ||
98 | } | ||
99 | |||
100 | #---------------------------------------------------------------------- | ||
101 | # | ||
102 | # supported options: | ||
103 | # start | ||
104 | # stop | ||
105 | # reload: reloads the exports file | ||
106 | # restart: stops and starts mountd | ||
107 | #FIXME: need to create the /var/lib/nfs/... directories | ||
108 | case "$1" in | ||
109 | start) | ||
110 | start_nfsd "$NFS_SERVERS" | ||
111 | start_mountd | ||
112 | test -r /etc/exports && exportfs -a;; | ||
113 | stop) exportfs -ua | ||
114 | stop_mountd | ||
115 | stop_nfsd;; | ||
116 | status) | ||
117 | status /usr/sbin/rpc.mountd | ||
118 | RETVAL=$? | ||
119 | status nfsd | ||
120 | rval=$? | ||
121 | [ $RETVAL -eq 0 ] && exit $rval | ||
122 | exit $RETVAL;; | ||
123 | reload) test -r /etc/exports && exportfs -r;; | ||
124 | restart) | ||
125 | $0 stop | ||
126 | $0 start;; | ||
127 | *) echo "Usage: $0 {start|stop|status|reload|restart}" | ||
128 | exit 1;; | ||
129 | esac | ||