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
28 if [ -x /opt/openafs/sbin/afsd ] ; then
29 AFSD=/opt/openafs/sbin/afsd
33 CONFIG=$VICEETC/config
34 AFSDOPT=$CONFIG/afsd.options
35 PACKAGE=$CONFIG/package.options
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"
41 if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi
42 if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi
44 if [ -f $CONFIG/afs.conf ]; then
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`
56 echo "Starting OpenAFS"
58 if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
59 AFSD_OPTIONS="$VERBOSE"
61 AFSD_OPTIONS="$OPTIONS $VERBOSE"
64 if [ "${NETWORKUP}" = "-NO-" ]; then
65 echo $AFSD_OPTIONS | grep -e '-dynroot' || exit
68 # Need the commands ps, awk, kill, sleep
69 PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
71 if [ -d $VICEETC/afs.kext ]; then
72 echo "Loading AFS kernel extensions"
73 kextload $VICEETC/afs.kext
75 echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
79 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
82 echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
87 # Start the AFS server processes if a bosserver exists
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"
98 # Check that all of the client configuration files exist
101 for file in $AFSD $VICEETC/cacheinfo \
102 $VICEETC/ThisCell $VICEETC/CellServDB
104 if [ ! -f ${file} ]; then
105 echo "${file} does not exist. Not starting AFS client."
111 # Check that the root directory for AFS (/afs)
112 # and the cache directory (/usr/vice/cache) both exist
115 for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
117 if [ ! -d ${dir} ]; then
118 echo "${dir} does not exist. Not starting AFS client."
127 # From /var/db/openafs/etc/config/afs.conf, call a post-init function or
128 # command if it's been defined
133 # Call afssettings (if it exists) to set customizable parameters
135 if [ -x $CONFIG/afssettings ]; then
141 # From /var/db/openafs/etc/config/afs.conf, set a sysname list if one was
144 if [ -n "$AFS_SYSNAME" ] ; then
145 fs sysname $AFS_SYSNAME
148 if [ ! -z "$PRECACHE" ] ; then
149 fs precache $AFS_PRECACHE
153 # Run package to update the disk
155 if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
156 /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
159 (echo "Package completed successfully") > /dev/console 2>&1
160 date > /dev/console 2>&1
163 (echo "Rebooting to restart system") > /dev/console 2>&1
168 (echo "Package update failed; continuing") > /dev/console 2>&1
174 # Start AFS inetd services
175 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
177 if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
178 /usr/sbin/inetd.afs /etc/inetd.conf.afs
187 # If a pre-shutdown function was defined in /var/db/openafs/etc/config/afs.conf
188 # was defined, then run it
192 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
193 echo "Unmounting /afs"
194 umount -f /afs 2>&1 > /dev/console
196 echo "Shutting down afsd processes"
197 $AFSD -shutdown 2>&1 > /dev/console
199 echo "Unloading AFS kernel extensions"
200 kextunload $VICEETC/afs.kext 2>&1 > /dev/console
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
216 RunService "${1:-start}"