ed0509004cf6ff4040e2614751a4fa90ed97e3cd
[openafs.git] / src / afsd / afs.rc.darwin
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 . /etc/rc.common
10
11 CheckForNetwork 
12
13 if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi
14
15 if [ -r /var/db/openafs ]; then
16    VICEETC=/var/db/openafs/etc
17    AFSD=/usr/sbin/afsd
18 else
19    VICEETC=/usr/vice/etc
20    AFSD=$VICEETC/afsd
21 fi
22 CONFIG=$VICEETC/config
23 AFSDOPT=$CONFIG/afsd.options
24 PACKAGE=$CONFIG/package.options
25
26 LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
27 MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
28 SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
29
30 if [ -f $AFSDOPT ]; then
31     OPTIONS=`cat $AFSDOPT`
32 else
33     OPTIONS=$MEDIUM
34 fi
35
36 # Need the commands ps, awk, kill, sleep
37 PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
38 if kmodstat | grep -q openafs ; then
39 :
40 else
41 if [ -d $VICEETC/afs.kext ]; then
42         echo "Loading AFS kernel extensions"
43         kextload $VICEETC/afs.kext
44 else
45         echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
46         exit 1
47 fi
48 fi
49 if kmodstat | grep -q openafs ; then
50 :
51 else
52         echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
53         exit 1
54 fi
55
56 #
57 # Start the AFS server processes if a bosserver exists
58 #
59
60 if [ -x /usr/afs/bin/bosserver ]; then
61         echo "Starting AFS Server processes"
62         /usr/afs/bin/bosserver
63         OPTIONS="$OPTIONS -nosettime"
64         sleep 30
65 fi
66
67 #
68 # Check that all of the client configuration files exist
69 #
70
71 for file in $AFSD $VICEETC/cacheinfo \
72             $VICEETC/ThisCell $VICEETC/CellServDB
73 do
74         if [ ! -f ${file} ]; then
75                 echo "${file} does not exist. Not starting AFS client."
76                 exit 1
77         fi
78 done
79
80 #
81 # Check that the root directory for AFS (/afs) 
82 # and the cache directory (/usr/vice/cache) both exist
83 #
84
85 for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
86 do
87         if [ ! -d ${dir} ]; then
88                 echo "${dir} does not exist. Not starting AFS client."
89                 exit 2
90         fi
91 done
92
93 echo "Starting afsd"
94 $AFSD $OPTIONS
95
96 #
97 # Run package to update the disk
98 #
99 if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
100         /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
101 case $? in
102 0)
103         (echo "Package completed successfully") > /dev/console 2>&1
104         date > /dev/console 2>&1
105         ;;
106 4)
107         (echo "Rebooting to restart system") > /dev/console 2>&1
108         sync
109         /sbin/reboot
110         ;;
111 *)
112         (echo "Package update failed; continuing") > /dev/console 2>&1
113         ;;
114 esac
115
116 fi
117
118 #
119 # Start AFS inetd services
120 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
121 #
122 if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
123         /usr/sbin/inetd.afs /etc/inetd.conf.afs
124 fi