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 | # Portions Copyright (c) 2003 Apple Computer, Inc. | |
10 | # | |
11 | # Updated to match standard service scripts | |
12 | # Phil Holland <hollandp@umich.edu> 6/11/04 | |
13 | ||
14 | PRECACHE="$AFS_PRECACHE" | |
15 | ||
16 | . /etc/rc.common | |
17 | ||
18 | # | |
19 | # Variable Definition Section | |
20 | # | |
21 | CheckForNetwork | |
22 | ||
23 | VICEETC=/usr/vice/etc | |
24 | AFSD=$VICEETC/afsd | |
25 | if [ -r /var/db/openafs ]; then | |
26 | VICEETC=/var/db/openafs/etc | |
27 | AFSD=/usr/sbin/afsd | |
28 | if [ -x /opt/openafs/sbin/afsd ] ; then | |
29 | AFSD=/opt/openafs/sbin/afsd | |
30 | fi | |
31 | fi | |
32 | ||
33 | CONFIG=$VICEETC/config | |
34 | AFSDOPT=$CONFIG/afsd.options | |
35 | PACKAGE=$CONFIG/package.options | |
36 | ||
37 | LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128" | |
38 | MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70" | |
39 | SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50" | |
40 | ||
41 | if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi | |
42 | if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi | |
43 | ||
44 | if [ -f $CONFIG/afs.conf ]; then | |
45 | . $CONFIG/afs.conf | |
46 | fi | |
47 | ||
48 | # Check this file second so that if users have altered the file, it will | |
49 | # override the default options | |
50 | if [ -f $AFSDOPT ]; then | |
51 | OPTIONS=`cat $AFSDOPT` | |
52 | fi | |
53 | ||
54 | StartService() | |
55 | { | |
56 | echo "Starting OpenAFS" | |
57 | ||
58 | if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then | |
59 | AFSD_OPTIONS="$VERBOSE" | |
60 | else | |
61 | AFSD_OPTIONS="$OPTIONS $VERBOSE" | |
62 | fi | |
63 | ||
64 | if [ "${NETWORKUP}" = "-NO-" ]; then | |
65 | echo $AFSD_OPTIONS | grep -e '-dynroot' || exit | |
66 | fi | |
67 | ||
68 | # Need the commands ps, awk, kill, sleep | |
69 | PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin | |
70 | ||
71 | if [ -d $VICEETC/afs.kext ]; then | |
72 | echo "Loading AFS kernel extensions" | |
73 | kextload $VICEETC/afs.kext | |
74 | else | |
75 | echo "$VICEETC/afs.kext does not exist. Skipping AFS startup." | |
76 | exit 1 | |
77 | fi | |
78 | ||
79 | if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then | |
80 | : | |
81 | else | |
82 | echo "AFS kernel extensions failed to initialize. Skipping AFS startup." | |
83 | exit 1 | |
84 | fi | |
85 | ||
86 | # | |
87 | # Start the AFS server processes if a bosserver exists | |
88 | # | |
89 | ||
90 | if [ -x /usr/afs/bin/bosserver -a -f /usr/afs/local/BosConfig ]; then | |
91 | echo "Starting AFS Server processes" | |
92 | /usr/afs/bin/bosserver | |
93 | AFSD_OPTIONS="$AFSD_OPTIONS -nosettime" | |
94 | sleep 30 | |
95 | fi | |
96 | ||
97 | # | |
98 | # Check that all of the client configuration files exist | |
99 | # | |
100 | ||
101 | for file in $AFSD $VICEETC/cacheinfo \ | |
102 | $VICEETC/ThisCell $VICEETC/CellServDB | |
103 | do | |
104 | if [ ! -f ${file} ]; then | |
105 | echo "${file} does not exist. Not starting AFS client." | |
106 | exit 1 | |
107 | fi | |
108 | done | |
109 | ||
110 | # | |
111 | # Check that the root directory for AFS (/afs) | |
112 | # and the cache directory (/usr/vice/cache) both exist | |
113 | # | |
114 | ||
115 | for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo` | |
116 | do | |
117 | if [ ! -d ${dir} ]; then | |
118 | echo "${dir} does not exist. Not starting AFS client." | |
119 | exit 2 | |
120 | fi | |
121 | done | |
122 | ||
123 | echo "Starting afsd" | |
124 | $AFSD $AFSD_OPTIONS | |
125 | ||
126 | # | |
127 | # From /var/db/openafs/etc/config/afs.conf, call a post-init function or | |
128 | # command if it's been defined | |
129 | # | |
130 | $AFS_POST_INIT | |
131 | ||
132 | # | |
133 | # Call afssettings (if it exists) to set customizable parameters | |
134 | # | |
135 | if [ -x $CONFIG/afssettings ]; then | |
136 | sleep 2 | |
137 | $CONFIG/afssettings | |
138 | fi | |
139 | ||
140 | # | |
141 | # From /var/db/openafs/etc/config/afs.conf, set a sysname list if one was | |
142 | # configured. | |
143 | # | |
144 | if [ -n "$AFS_SYSNAME" ] ; then | |
145 | fs sysname $AFS_SYSNAME | |
146 | fi | |
147 | ||
148 | if [ ! -z "$PRECACHE" ] ; then | |
149 | fs precache $AFS_PRECACHE | |
150 | fi | |
151 | ||
152 | # | |
153 | # Run package to update the disk | |
154 | # | |
155 | if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then | |
156 | /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1 | |
157 | case $? in | |
158 | 0) | |
159 | (echo "Package completed successfully") > /dev/console 2>&1 | |
160 | date > /dev/console 2>&1 | |
161 | ;; | |
162 | 4) | |
163 | (echo "Rebooting to restart system") > /dev/console 2>&1 | |
164 | sync | |
165 | /sbin/reboot | |
166 | ;; | |
167 | *) | |
168 | (echo "Package update failed; continuing") > /dev/console 2>&1 | |
169 | ;; | |
170 | esac | |
171 | fi | |
172 | ||
173 | # | |
174 | # Start AFS inetd services | |
175 | # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs) | |
176 | # | |
177 | if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then | |
178 | /usr/sbin/inetd.afs /etc/inetd.conf.afs | |
179 | fi | |
180 | } | |
181 | ||
182 | StopService() | |
183 | { | |
184 | echo "Stopping AFS" | |
185 | ||
186 | # | |
187 | # If a pre-shutdown function was defined in /var/db/openafs/etc/config/afs.conf | |
188 | # was defined, then run it | |
189 | # | |
190 | $AFS_PRE_SHUTDOWN | |
191 | ||
192 | if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then | |
193 | echo "Unmounting /afs" | |
194 | umount -f /afs 2>&1 > /dev/console | |
195 | ||
196 | echo "Shutting down afsd processes" | |
197 | $AFSD -shutdown 2>&1 > /dev/console | |
198 | ||
199 | echo "Unloading AFS kernel extensions" | |
200 | kextunload $VICEETC/afs.kext 2>&1 > /dev/console | |
201 | fi | |
202 | ||
203 | if [ -x /usr/afs/bin/bosserver -a -f /usr/afs/local/BosConfig ]; then | |
204 | echo "Stopping AFS Server processes" | |
205 | /usr/afs/bin/bos shutdown localhost -local | |
206 | killall bosserver | |
207 | fi | |
208 | } | |
209 | ||
210 | RestartService() | |
211 | { | |
212 | StopService | |
213 | StartService | |
214 | } | |
215 | ||
216 | RunService "${1:-start}" |