]>
Commit | Line | Data |
---|---|---|
e91b9f68 A |
1 | #!/bin/sh |
2 | ||
3 | ## | |
4 | # Network File System | |
5 | ## | |
6 | ||
7 | . /etc/rc.common | |
8 | ||
9 | AUTOMOUNTDIR=/private/var/automount | |
10 | ||
11 | StartService () | |
12 | { | |
13 | CheckForNetwork | |
14 | if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi | |
15 | lockfile -r 0 /var/run/NFS.StartupItem || exit 0 | |
16 | ||
17 | ## | |
18 | # Set up NFS client. | |
19 | ## | |
20 | echo "Starting network file system" | |
21 | ||
22 | if [ -d ${AUTOMOUNTDIR} ]; then | |
23 | chflags -R nouchg ${AUTOMOUNTDIR} | |
24 | rm -rf ${AUTOMOUNTDIR} | |
25 | fi | |
26 | ||
27 | # nsfiod is the NFS asynchronous block I/O daemon, which implements | |
28 | # NFS read-ahead and write-behind caching on NFS clients. | |
29 | nfsiod -n 4 | |
30 | ||
31 | ## | |
32 | # The rpc.lockd/rpc.statd daemons are needed on both the client and | |
33 | # the server in order to support file locking over NFS. | |
34 | # | |
35 | # If NFSLOCKS = -AUTOMATIC-, we start the daemons if we are a server | |
36 | # but if we are only a client, we start the daemons once we know we | |
37 | # need them. | |
38 | ## | |
39 | ||
40 | ## | |
41 | # gather list of NFS exports | |
42 | ## | |
43 | exports_ni=$(niutil -list . /exports 2> /dev/null | wc -w) | |
44 | # Look for exports in /etc/exports, ignoring comments and blank lines. | |
45 | exports_etc=$(grep -v '^[[:space:]]*\(#\|$\)' /etc/exports 2> /dev/null | wc -l) | |
46 | exports=$(($exports_ni + $exports_etc)) | |
47 | ||
48 | # if we are an NFS server, turn on NFS locking by default: | |
49 | if [ "${exports}" -gt 0 ]; then | |
50 | if [ "${NFSLOCKS:=-AUTOMATIC-}" = "-AUTOMATIC-" ]; then | |
51 | NFSLOCKS=-YES-; | |
52 | fi | |
53 | fi | |
54 | ||
55 | if [ "${NFSLOCKS:=-AUTOMATIC-}" = "-YES-" ]; then | |
56 | # we definitely want locks on, so turn them on now | |
57 | rpc.statd | |
58 | rpc.lockd | |
59 | fi | |
60 | if [ "${NFSLOCKS:=-AUTOMATIC-}" = "-AUTOMATIC-" ]; then | |
61 | # delay starting daemons until we know we need them | |
62 | ||
63 | # invoke rpc.statd to send any SM_NOTIFY messages and quit. | |
64 | rpc.statd -n | |
65 | ||
66 | # -w says to wait for signal from kernel, then start daemons | |
67 | rpc.lockd -w | |
68 | fi | |
69 | ||
70 | ## | |
71 | # Set up NFS server. | |
72 | ## | |
73 | ||
74 | # If exportfs finds something to export (either using /etc/exports or the | |
75 | # exports NetInfo directory), then start the NFS daemons (which service | |
76 | # NFS requests) and the mount server (which services NFS mount requests). | |
77 | ||
78 | # Clear the table of exported filesystems. | |
79 | rm -f /var/db/mountdtab | |
80 | ||
81 | if [ "${exports}" -gt 0 ]; then | |
82 | echo "Starting Network File System server" | |
83 | mountd | |
84 | ||
85 | # If the NetInfo config/nfsd directory contains startup args for nfsd, use those. | |
86 | arguments=`niutil -readprop . /config/nfsd arguments` | |
87 | if [ "${arguments}" = "" ]; then | |
88 | arguments="-t -u -n 6" | |
89 | fi | |
90 | nfsd ${arguments} | |
91 | fi | |
92 | ||
93 | ## | |
94 | # Start the automounter | |
95 | ## | |
96 | ||
97 | if [ "${AUTOMOUNT:=-YES-}" = "-YES-" ]; then | |
98 | automount -m /Network -nsl -mnt ${AUTOMOUNTDIR} | |
99 | ln -s /automount/Library /Network/Library | |
100 | automount -m /automount/Servers -fstab -mnt /private/Network/Servers \ | |
101 | -m /automount/static -static -mnt ${AUTOMOUNTDIR} | |
102 | ln -s /automount/Servers /Network/Servers | |
103 | ||
104 | # | |
105 | # Hint that the name /Network should be localized: | |
106 | # | |
107 | ln -s . /Network/.localized | |
108 | fi | |
109 | ||
110 | # | |
111 | # Leave a mark upon completion of the automounter startup: | |
112 | # | |
113 | touch /var/run/automount.initialized | |
114 | } | |
115 | ||
116 | StopService () | |
117 | { | |
118 | return 0 | |
119 | } | |
120 | ||
121 | RestartService () | |
122 | { | |
123 | return 0 | |
124 | } | |
125 | ||
126 | RunService "$1" |