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 # Portions Copyright (c) 2003 Apple Computer, Inc.
11 # Updated to match standard service scripts
12 # Phil Holland <hollandp@umich.edu> 6/11/04
14 PRECACHE="$AFS_PRECACHE"
19 # Variable Definition Section
25 if [ -r /var/db/openafs ]; then
26 VICEETC=/var/db/openafs/etc
30 CONFIG=$VICEETC/config
31 AFSDOPT=$CONFIG/afsd.options
32 PACKAGE=$CONFIG/package.options
34 LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
35 MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
36 SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
38 if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi
39 if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi
41 if [ -f $CONFIG/afs.conf ]; then
45 # Check this file second so that if users have altered the file, it will
46 # override the default options
47 if [ -f $AFSDOPT ]; then
48 OPTIONS=`cat $AFSDOPT`
53 echo "Starting OpenAFS"
55 if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
56 AFSD_OPTIONS="$VERBOSE"
58 AFSD_OPTIONS="$OPTIONS $VERBOSE"
61 if [ "${NETWORKUP}" = "-NO-" ]; then
62 echo $AFSD_OPTIONS | grep -e '-dynroot' || exit
65 # Need the commands ps, awk, kill, sleep
66 PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
68 if [ -d $VICEETC/afs.kext ]; then
69 echo "Loading AFS kernel extensions"
70 kextload $VICEETC/afs.kext
72 echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
76 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
79 echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
84 # Start the AFS server processes if a bosserver exists
87 if [ -x /usr/afs/bin/bosserver -a -f /usr/afs/local/BosConfig ]; then
88 echo "Starting AFS Server processes"
89 /usr/afs/bin/bosserver
90 AFSD_OPTIONS="$AFSD_OPTIONS -nosettime"
95 # Check that all of the client configuration files exist
98 for file in $AFSD $VICEETC/cacheinfo \
99 $VICEETC/ThisCell $VICEETC/CellServDB
101 if [ ! -f ${file} ]; then
102 echo "${file} does not exist. Not starting AFS client."
108 # Check that the root directory for AFS (/afs)
109 # and the cache directory (/usr/vice/cache) both exist
112 for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
114 if [ ! -d ${dir} ]; then
115 echo "${dir} does not exist. Not starting AFS client."
124 # From /var/db/openafs/etc/config/afs.conf, call a post-init function or
125 # command if it's been defined
130 # Call afssettings (if it exists) to set customizable parameters
132 if [ -x $CONFIG/afssettings ]; then
138 # From /var/db/openafs/etc/config/afs.conf, set a sysname list if one was
141 if [ -n "$AFS_SYSNAME" ] ; then
142 fs sysname $AFS_SYSNAME
145 if [ ! -z "$PRECACHE" ] ; then
146 fs precache $AFS_PRECACHE
150 # Run package to update the disk
152 if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
153 /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
156 (echo "Package completed successfully") > /dev/console 2>&1
157 date > /dev/console 2>&1
160 (echo "Rebooting to restart system") > /dev/console 2>&1
165 (echo "Package update failed; continuing") > /dev/console 2>&1
171 # Start AFS inetd services
172 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
174 if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
175 /usr/sbin/inetd.afs /etc/inetd.conf.afs
184 # If a pre-shutdown function was defined in /var/db/openafs/etc/config/afs.conf
185 # was defined, then run it
189 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
190 echo "Unmounting /afs"
191 umount -f /afs 2>&1 > /dev/console
193 echo "Shutting down afsd processes"
194 $AFSD -shutdown 2>&1 > /dev/console
196 echo "Unloading AFS kernel extensions"
197 kextunload $VICEETC/afs.kext 2>&1 > /dev/console
200 if [ -x /usr/afs/bin/bosserver -a -f /usr/afs/local/BosConfig ]; then
201 echo "Stopping AFS Server processes"
202 /usr/afs/bin/bos shutdown localhost -local
213 RunService "${1:-start}"