diff options
author | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-03-22 18:31:40 +0000 |
---|---|---|
committer | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-03-22 18:31:40 +0000 |
commit | f40f63143b48e2ec2572b31f101621f02dd77138 (patch) | |
tree | e5608c39da8971f80c525a35ce7f0b3ea94d30b3 /meta/packages/nfs-utils/files/nfsserver | |
parent | 6b86555e703297cba0431c8708efa2aacae5ce8c (diff) | |
download | poky-f40f63143b48e2ec2572b31f101621f02dd77138.tar.gz |
nfs-utils: moved from meta-extras to meta
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1385 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/nfs-utils/files/nfsserver')
-rw-r--r-- | meta/packages/nfs-utils/files/nfsserver | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/meta/packages/nfs-utils/files/nfsserver b/meta/packages/nfs-utils/files/nfsserver new file mode 100644 index 0000000000..4ff75916d0 --- /dev/null +++ b/meta/packages/nfs-utils/files/nfsserver | |||
@@ -0,0 +1,132 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Startup script for nfs-utils | ||
4 | # | ||
5 | # The nfsd kernel module must exist along with its dependencies | ||
6 | modprobe -n nfsd || exit 0 | ||
7 | # | ||
8 | # The environment variable NFS_SERVERS may be set in /etc/default/nfsd | ||
9 | # Other control variables may be overridden here too | ||
10 | test -r /etc/default/nfsd && . /etc/default/nfsd | ||
11 | # | ||
12 | # Location of exectuables: | ||
13 | test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/mountd | ||
14 | test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/nfsd | ||
15 | # | ||
16 | # The user mode program must also exist (it just starts the kernel | ||
17 | # threads using the kernel module code). | ||
18 | test -x "$NFS_MOUNTD" || exit 0 | ||
19 | test -x "$NFS_NFSD" || exit 0 | ||
20 | # | ||
21 | # Default is 8 threads, value is settable between 1 and the truely | ||
22 | # ridiculous 99 | ||
23 | test "$NFS_SERVERS" -gt 0 && test "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8 | ||
24 | # | ||
25 | # The default state directory is /var/lib/nfs | ||
26 | test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs | ||
27 | # | ||
28 | #---------------------------------------------------------------------- | ||
29 | # Startup and shutdown functions. | ||
30 | # Actual startup/shutdown is at the end of this file. | ||
31 | #directories | ||
32 | create_directories(){ | ||
33 | echo -n 'creating NFS state directory: ' | ||
34 | mkdir -p "$NFS_STATEDIR" | ||
35 | ( cd "$NFS_STATEDIR" | ||
36 | umask 077 | ||
37 | mkdir -p sm sm.bak | ||
38 | test -w sm/state || { | ||
39 | rm -f sm/state | ||
40 | :>sm/state | ||
41 | } | ||
42 | umask 022 | ||
43 | for file in xtab etab smtab rmtab | ||
44 | do | ||
45 | test -w "$file" || { | ||
46 | rm -f "$file" | ||
47 | :>"$file" | ||
48 | } | ||
49 | done | ||
50 | ) | ||
51 | echo done | ||
52 | } | ||
53 | #mountd | ||
54 | start_mountd(){ | ||
55 | echo -n 'starting mountd: ' | ||
56 | start-stop-daemon --start --exec "$NFS_MOUNTD" -- "-f /etc/exports $@" | ||
57 | echo done | ||
58 | } | ||
59 | stop_mountd(){ | ||
60 | echo -n 'stopping mountd: ' | ||
61 | start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD" | ||
62 | echo done | ||
63 | } | ||
64 | # | ||
65 | #nfsd | ||
66 | start_nfsd(){ | ||
67 | echo -n "starting $1 nfsd kernel threads: " | ||
68 | start-stop-daemon --start --exec "$NFS_NFSD" -- "$@" | ||
69 | echo done | ||
70 | } | ||
71 | delay_nfsd(){ | ||
72 | for delay in 0 1 2 3 4 5 6 7 8 9 | ||
73 | do | ||
74 | if pidof nfsd >/dev/null | ||
75 | then | ||
76 | echo -n . | ||
77 | sleep 1 | ||
78 | else | ||
79 | return 0 | ||
80 | fi | ||
81 | done | ||
82 | return 1 | ||
83 | } | ||
84 | stop_nfsd(){ | ||
85 | # WARNING: this kills any process with the executable | ||
86 | # name 'nfsd'. | ||
87 | echo -n 'stopping nfsd: ' | ||
88 | start-stop-daemon --stop --quiet --signal 1 --name nfsd | ||
89 | if delay_nfsd || { | ||
90 | echo failed | ||
91 | echo ' using signal 9: ' | ||
92 | start-stop-daemon --stop --quiet --signal 9 --name nfsd | ||
93 | delay_nfsd | ||
94 | } | ||
95 | then | ||
96 | echo done | ||
97 | # This will remove, recursively, dependencies | ||
98 | echo -n 'removing nfsd kernel module: ' | ||
99 | if modprobe -r nfsd | ||
100 | then | ||
101 | echo done | ||
102 | else | ||
103 | echo failed | ||
104 | fi | ||
105 | else | ||
106 | echo failed | ||
107 | fi | ||
108 | } | ||
109 | #---------------------------------------------------------------------- | ||
110 | # | ||
111 | # supported options: | ||
112 | # start | ||
113 | # stop | ||
114 | # reload: reloads the exports file | ||
115 | # restart: stops and starts mountd | ||
116 | #FIXME: need to create the /var/lib/nfs/... directories | ||
117 | case "$1" in | ||
118 | start) create_directories | ||
119 | start_nfsd "$NFS_SERVERS" | ||
120 | start_mountd | ||
121 | test -r /etc/exports && exportfs -a;; | ||
122 | stop) exportfs -ua | ||
123 | stop_mountd | ||
124 | stop_nfsd;; | ||
125 | reload) test -r /etc/exports && exportfs -r;; | ||
126 | restart)exportfs -ua | ||
127 | stop_mountd | ||
128 | # restart does not restart the kernel threads, | ||
129 | # only the user mode processes | ||
130 | start_mountd | ||
131 | test -r /etc/exports && exportfs -a;; | ||
132 | esac | ||