Commit | Line | Data |
---|---|---|
805e021f CE |
1 | #!/bin/sh |
2 | # Copyright 2000, International Business Machines Corporation and others. | |
3 | # All Rights Reserved. | |
4 | # | |
5 | # This software has been released under the terms of the IBM Public | |
6 | # License. For details, see the LICENSE file in the top-level source | |
7 | # directory or online at http://www.openafs.org/dl/license10.html | |
8 | ||
9 | # afs.rc: rc script for AFS on SGI Irix platforms | |
10 | # | |
11 | # Install this script as /etc/init.d/afs | |
12 | # then make links like this: | |
13 | # ln -s ../init.d/afs /etc/rc0.d/K35afs | |
14 | # ln -s ../init.d/afs /etc/rc2.d/S35afs | |
15 | # | |
16 | # Config Files (in /etc/config) | |
17 | # afsclient - machine should be an AFS client | |
18 | # afsserver - machine should be an AFS server | |
19 | # afsxnfs - machine should be an AFS/NFS translator (must also be | |
20 | # an AFS client) | |
21 | # afsml - dynamically load afs (using ml(1M)) | |
22 | # | |
23 | # Option files (in /etc/config) | |
24 | # afsd.options - options to pass to afsd. If present it overrides | |
25 | # the defaults here. | |
26 | # | |
27 | # The following are 'recommended' values for various sized machines. | |
28 | # These options should be given in /etc/config/afsd.options. | |
29 | # If afsd.options does not exist then $OPTIONS is used. | |
30 | # | |
31 | ||
32 | # EXTRAOPTS can be used to enable/disable AFSDB support (-afsdb) | |
33 | # and Dynroot (dynamically-generated /afs) support (-dynroot). | |
34 | EXTRAOPTS="-afsdb" | |
35 | ||
36 | LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128" | |
37 | MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70" | |
38 | SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50" | |
39 | OPTIONS="$MEDIUM $EXTRAOPTS" | |
40 | ||
41 | CONFIG=/etc/config | |
42 | IS_ON=/etc/chkconfig | |
43 | AFSDOPT=$CONFIG/afsd.options | |
44 | AFSMT=/afs | |
45 | COMMON_CLIENT=0 | |
46 | ||
47 | # The verbose flag controls the printing of the names of daemons as they | |
48 | # are started | |
49 | ||
50 | if $IS_ON verbose ; then | |
51 | ECHO=echo | |
52 | VERBOSE=-v | |
53 | else # For a quiet startup and shutdown | |
54 | ECHO=: | |
55 | VERBOSE= | |
56 | fi | |
57 | ||
58 | # | |
59 | # Run afsd in -nosettime mode if we have an alternative time sync | |
60 | # OR we are a server and a client machine | |
61 | # | |
62 | if $IS_ON timed || $IS_ON timeslave || \ | |
63 | ( $IS_ON afsserver && $IS_ON afsclient ) ; then | |
64 | TIMESYNC=-nosettime | |
65 | fi | |
66 | ||
67 | case "$1" in | |
68 | 'netstart') | |
69 | # The network startup script (/etc/init.d/network) used to run | |
70 | # "/etc/init.d/afs netstart" to accomodate the loading of AFS 3.3 | |
71 | # at a particular time relative to NFS. In AFS 3.4, we need to | |
72 | # start up after the network script has completed, so the 'netstart' | |
73 | # option is now a no-op and the 'start' option loads AFS. | |
74 | ;; | |
75 | 'start') | |
76 | ||
77 | if $IS_ON afsml | |
78 | then | |
79 | # | |
80 | # Figure out what kind of machine we're on. | |
81 | # | |
82 | CPU=`hinv -t cpu` | |
83 | OS_VERS=`uname -r` | |
84 | if echo $OS_VERS | fgrep 6.4 > /dev/null | |
85 | then | |
86 | COMMON_CLIENT=1 | |
87 | elif echo $CPU | fgrep R3000 >/dev/null | |
88 | then | |
89 | CPU=R3000 | |
90 | elif echo $CPU | egrep 'R4000|R4400|4600' >/dev/null | |
91 | then | |
92 | # R4xxx series can be either 32 or 64 bit kernels. | |
93 | # Based on OS and CPUBOARD | |
94 | CPU=R4000 | |
95 | if echo $OS_VERS | fgrep 6.2 > /dev/null | |
96 | then | |
97 | IP_TYPE=`uname -m` | |
98 | if echo $IP_TYPE | egrep '17|20|22' > /dev/null | |
99 | then | |
100 | CPU=R4000_32 | |
101 | fi | |
102 | fi | |
103 | elif echo $CPU | egrep R5000 >/dev/null | |
104 | then | |
105 | # For 6.3, we have an R5000 library. | |
106 | if echo $OS_VERS | fgrep 6.3 > /dev/null | |
107 | then | |
108 | CPU=R5000 | |
109 | else | |
110 | CPU=R4000_32 | |
111 | fi | |
112 | elif echo $CPU | egrep R8000 >/dev/null | |
113 | then | |
114 | CPU=R8000 | |
115 | elif echo $CPU | egrep R10000 >/dev/null | |
116 | then | |
117 | CPU=R10000 | |
118 | else | |
119 | echo "Cannot determine system type: $CPU not understood" | |
120 | echo "Aborting AFS start" | |
121 | exit 1 | |
122 | fi | |
123 | ||
124 | # | |
125 | # Figure out if the machine is a multiprocessor or uniprocessor | |
126 | # or both | |
127 | # | |
128 | if [ $COMMON_CLIENT = 1 ] | |
129 | then | |
130 | # | |
131 | # Figure out if we need the .nonfs library | |
132 | # | |
133 | if [ -r /etc/havenfs -a /etc/havenfs ]; | |
134 | then | |
135 | NAME="libafs.o" | |
136 | else | |
137 | NAME="libafs.nonfs.o" | |
138 | fi | |
139 | else | |
140 | ARCH=`hinv | awk '/Processor/ && /MHZ/ {print $1}'` | |
141 | if test `echo $ARCH | wc -w` -gt 1 | |
142 | then | |
143 | ARCH=MP | |
144 | elif test $ARCH -eq 1 | |
145 | then | |
146 | ARCH=SP | |
147 | elif test $ARCH -gt 1 | |
148 | then | |
149 | ARCH=MP | |
150 | else | |
151 | echo "Cannot determine if system is MP or SP" | |
152 | echo "Aborting AFS start" | |
153 | exit 1 | |
154 | fi | |
155 | ||
156 | # | |
157 | # Figure out if we need the .nonfs library | |
158 | # | |
159 | if [ -r /etc/havenfs -a /etc/havenfs ]; | |
160 | then | |
161 | NAME="libafs.${ARCH}.${CPU}.o" | |
162 | else | |
163 | NAME="libafs.${ARCH}.${CPU}.nonfs.o" | |
164 | fi | |
165 | fi | |
166 | # End of COMMON_CLIENT | |
167 | ||
168 | if [ -r /usr/afs/bin/sgiload/$NAME ] | |
169 | then | |
170 | MOD=/usr/afs/bin/sgiload/$NAME | |
171 | elif [ -r /usr/vice/etc/sgiload/$NAME ] | |
172 | then | |
173 | MOD=/usr/vice/etc/sgiload/$NAME | |
174 | else | |
175 | echo "Cannot find afs kernel library: $NAME" | |
176 | echo "Aborting AFS start" | |
177 | exit 1 | |
178 | fi | |
179 | ||
180 | $ECHO "Loading AFS from $MOD...\c" | |
181 | if ml ld $VERBOSE -j $MOD -p Afs_ -a afs | |
182 | then | |
183 | : | |
184 | else | |
185 | echo "Dynamic load of AFS failed - Aborting AFS start" | |
186 | exit 1 | |
187 | fi | |
188 | else | |
189 | $ECHO "Not loading AFS kernel extensions - afsml config option is off" | |
190 | fi | |
191 | ||
192 | if $IS_ON afsserver && test -x /usr/afs/bin/bosserver | |
193 | then | |
194 | $ECHO "Starting AFS bosserver" | |
195 | /usr/afs/bin/bosserver >/dev/console 2>&1 | |
196 | fi | |
197 | ||
198 | if $IS_ON afsclient && test -x /usr/vice/etc/afsd ; then | |
199 | if test -s /usr/vice/etc/ThisCell ; then | |
200 | MYCELL=`cat /usr/vice/etc/ThisCell` | |
201 | else | |
202 | echo "/usr/vice/etc/ThisCell not valid - Aborting AFS start" | |
203 | exit 1 | |
204 | fi | |
205 | if test -r $AFSDOPT ; then | |
206 | OPTIONS=`cat $AFSDOPT` | |
207 | fi | |
208 | if $IS_ON afsxnfs ; then | |
209 | OPTIONS="$OPTIONS -rmtsys" | |
210 | fi | |
211 | /usr/vice/etc/afsd $TIMESYNC $OPTIONS >/dev/console 2>&1 | |
212 | ||
213 | # Let AFS think for a while | |
214 | i=30 | |
215 | while test ! -x $AFSMT/$MYCELL -a $i -gt 0 ; do | |
216 | sleep 1 | |
217 | i=`expr $i - 1` | |
218 | done | |
219 | if test ! -x $AFSMT/$MYCELL ; then | |
220 | echo "Warning AFS initialization did not complete correctly" | |
221 | fi | |
222 | ||
223 | # now that /afs is mounted - start up alternate inetd | |
224 | AFSWS=$AFSMT/$MYCELL/@sys/usr/afsws | |
225 | if test -x $AFSWS/etc/inetd.afs -a -r $AFSWS/etc/inetd.conf ; then | |
226 | $ECHO "Starting AFS inetd" | |
227 | $AFSWS/etc/inetd.afs $AFSWS/etc/inetd.conf 2>/dev/null </dev/null& | |
228 | fi | |
229 | fi | |
230 | ||
231 | ;; | |
232 | ||
233 | 'stop') | |
234 | # | |
235 | # Stop the AFS inetd and server processes | |
236 | # Note that the afsd processes cannot be killed | |
237 | # | |
238 | if $IS_ON afsclient ; then | |
239 | killall inetd.afs | |
240 | fi | |
241 | ||
242 | if $IS_ON afsserver && test -x /usr/afs/bin/bos | |
243 | then | |
244 | $ECHO "Stopping AFS bosserver" | |
245 | /usr/afs/bin/bos shutdown localhost -localauth -wait | |
246 | killall -HUP bosserver | |
247 | fi | |
248 | ;; | |
249 | ||
250 | *) | |
251 | echo "usage: $0 {start|stop}" | |
252 | ;; | |
253 | esac |