2 # Copyright 2000, International Business Machines Corporation and others.
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
9 # AFS Start and stop AFS components
13 # description: AFS is a distributed file system which provides location
14 # transparency, caching and secure authentication.
15 # Additional configuration can be done in the /etc/sysconfig/afs
16 # file. Read the documentation in that file for more information.
18 # The following section is used at least by SuSE insserv(8)
21 # Required-Start: $network
22 # Required-Stop: $network
24 # Default-Stop: 0 1 2 6
25 # Description: AFS is a distributed file system which provides location
26 # transparency, caching and secure authentication.
27 # Additional configuration can be done in the /etc/sysconfig/afs
28 # file. Read the documentation in that file for more information.
31 # Note that AFS does not use a pid file in /var/run. It is turned off by
35 # check for special bootup functions
36 if [ -f /etc/rc.d/init.d/functions ] ; then
37 . /etc/rc.d/init.d/functions
40 # special (RedHat) functions not available...
41 # so I provide neccessary replacements (e.g. for SuSE)
43 function echo_failure () { echo -n " - failed." ; }
45 function echo_success () { echo -n " - successful." ; }
47 # these are hopefully all functions I use...
53 if [ "$BOOTUP" = "color" ]; then
54 $* && echo_success || echo_failure
61 SYSCNF=/etc/sysconfig/afs
63 # Gather up options and post startup script name, if present
64 if [ -f $SYSCNF ] ; then
68 CACHEINFO=${CACHEINFO:-/usr/vice/etc/cacheinfo}
69 CACHE=${CACHEDIR:-/usr/vice/cache}
72 # is_on returns 1 if value of arg is "on"
74 if test "$1" = "on" ; then return 0
80 ADDRS=`ifconfig -a | grep 'inet addr' | grep -v 127.0.0.1 | wc -l`
81 if [ "$ADDRS" = "" ]; then
82 echo afs: No interfaces with IP address 1>&2
84 elif [ $ADDRS = 0 ]; then
85 echo afs: No interfaces with IP address 1>&2
91 # If choose_client can't correctly determine which client to use, set
95 # Use the second field of the uname -v output instead of just
96 # doing a match on the whole thing to protect against matching
97 # a timezone named SMP -- I don't know of one, but let's be
100 set X `uname -v`; shift
102 SMP) MP=.mp ;; # MP system
103 *) MP= ;; # SP system
106 # For now, just use uname -r to get the module version.
109 LIBAFS=libafs-$VERSION$MP.o
113 # Find prefix symbol to use with insmod. We find the unregister_filesystem
114 # string from /proc/ksyms since we know it's there. If /proc/ksyms does not
115 # exist, we print that info to the console and use the uname -v output to
116 # decide on a prefix.
117 # unregister_filesystem_Rsmp_b240cad8 is a typcial SMP version string from
118 # a kernel built from ftp.kernel.org
121 KSYMS_FILE=/proc/ksyms
122 SEARCH_STR="unregister_filesystem"
123 DEFAULT_SMP_PREFIX="smp_" # Redhat kernels need "smp" instead
124 PREFIX="" # none needed for UP with <= 1Gig memory
129 h8="$h$h$h$h$h$h$h$h"
132 set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift
139 # No versioning in kernel symbols
142 suffix=${str#${SEARCH_STR}_R}
148 echo afsd: Cannot find \"$SEARCH_STR\" in file $KSYMS_FILE
151 echo afsd: Malformed kernel version symbol \"$str\"
155 echo Guessing prefix from output of uname -v
156 set X `uname -v`; shift
159 PREFIX=$DEFAULT_SMP_PREFIX
166 MODLOADDIR=/usr/vice/etc/modload
167 # load_client loads the AFS client module if it's not already loaded.
169 # If LIBAFS is set, use it.
170 if [ -z "$LIBAFS" ] ; then
171 # Try to determine the right client.
175 if [ ! -f $MODLOADDIR/$LIBAFS ] ; then
176 echo AFS module $MODLOADDIR/$LIBAFS does not exist. Not starting AFS.
180 # use the prefix command if required
182 /sbin/insmod ${PREFIX:+-P $PREFIX} -f -m $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
185 generate_cacheinfo() {
186 if [ "$CACHESIZE" = "AUTOMATIC" ]; then
187 LINE=`df -k $CACHE | tail -1`
188 PART=`echo $LINE | awk '{ if ( ($NF != "/usr") && ($NF != "/") ) print $NF; else print "NONE";}'`
189 if [ "$PART" = "NONE" ]; then
190 echo "$CACHE or /usr/vice is not a separate partition"
191 echo "you have to change the cachesize in $SYSCNF by hand"
194 PARTSIZE=`echo $LINE | awk '{print $2}'`
195 CACHESIZE=`echo $PARTSIZE | awk '{printf "%d",int(($1*.8)/1000)*1000}'`
198 if [ "x$CACHESIZE" != "x" ]; then
199 echo $AFS:$CACHE:$CACHESIZE >$CACHEINFO
200 chmod 0644 $CACHEINFO
202 CACHESIZE=`awk -F: '{print $3}' < $CACHEINFO`
206 choose_afsdoptions() {
207 if [ -z "$OPTIONS" -o "$OPTIONS" = "AUTOMATIC" ]; then
208 if [ $CACHESIZE -lt 131072 ]; then
210 elif [ $CACHESIZE -lt 524288 ]; then
212 elif [ $CACHESIZE -lt 1048576 ]; then
214 elif [ $CACHESIZE -lt 2097152 ]; then
220 AFSD_OPTIONS="$OPTIONS $VERBOSE"
221 if is_on $ENABLE_AFSDB; then
222 AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"
224 if is_on $ENABLE_DYNROOT; then
225 AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"
231 if [ ! "$afs_rh" -o ! -f /var/lock/subsys/afs ]; then
233 # Load kernel extensions
234 if load_client ; then :
236 echo Failed to load AFS client, not starting AFS services.
240 echo "Starting AFS services..... "
241 # Start bosserver, it if exists
242 if is_on $AFS_SERVER && test -x /usr/afs/bin/bosserver ; then
243 /usr/afs/bin/bosserver
244 test "$afs_rh" && touch /var/lock/subsys/afs
248 if is_on $AFS_CLIENT && test -x /usr/vice/etc/afsd ; then
251 /usr/vice/etc/afsd ${AFSD_OPTIONS}
252 test "$afs_rh" && touch /var/lock/subsys/afs
259 if [ ! "$afs_rh" -o -f /var/lock/subsys/afs ]; then
261 echo "Stopping AFS services..... "
263 if is_on $AFS_CLIENT ; then
264 if [ -x /usr/vice/etc/killafs ] ; then
265 runcmd "Sending all processes using /afs the TERM signal ..." /usr/vice/etc/killafs TERM
266 runcmd "Sending all processes using /afs the KILL signal ..." /usr/vice/etc/killafs KILL
271 if is_on $AFS_SERVER && test -x /usr/bin/bos ; then
272 echo "Stopping AFS bosserver"
273 /usr/bin/bos shutdown localhost -localauth -wait
274 killall -HUP bosserver
277 LIBAFS=`/sbin/lsmod | fgrep libafs`
278 if [ -n "$LIBAFS" ] ; then
279 LIBAFS=`echo $LIBAFS | awk 'BEGIN { FS = " " } { print $1 }'`
283 rm -f /var/lock/subsys/afs
294 echo Usage: 'afs <start|stop|restart>'
300 action fool the Red Hat initscripts