ed95303ab8e23a747166f9817df809ba0e534c9b
[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 -fakestat"
34 fi
35
36 if [ -x /usr/sbin/kmodstat ]; then
37    KMODSTAT=/usr/sbin/kmodstat
38 else
39   if [ -x /usr/sbin/kextstat ]; then
40      KMODSTAT=/usr/sbin/kextstat
41 fi
42 fi
43
44 # Need the commands ps, awk, kill, sleep
45 PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
46 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
47 :
48 else
49 if [ -d $VICEETC/afs.kext ]; then
50         echo "Loading AFS kernel extensions"
51         kextload $VICEETC/afs.kext
52 else
53         echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
54         exit 1
55 fi
56 fi
57 if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
58 :
59 else
60         echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
61         exit 1
62 fi
63
64 #
65 # Start the AFS server processes if a bosserver exists
66 #
67
68 if [ -x /usr/afs/bin/bosserver ]; then
69         echo "Starting AFS Server processes"
70         /usr/afs/bin/bosserver
71         OPTIONS="$OPTIONS -nosettime"
72         sleep 30
73 fi
74
75 #
76 # Check that all of the client configuration files exist
77 #
78
79 for file in $AFSD $VICEETC/cacheinfo \
80             $VICEETC/ThisCell $VICEETC/CellServDB
81 do
82         if [ ! -f ${file} ]; then
83                 echo "${file} does not exist. Not starting AFS client."
84                 exit 1
85         fi
86 done
87
88 #
89 # Check that the root directory for AFS (/afs) 
90 # and the cache directory (/usr/vice/cache) both exist
91 #
92
93 for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
94 do
95         if [ ! -d ${dir} ]; then
96                 echo "${dir} does not exist. Not starting AFS client."
97                 exit 2
98         fi
99 done
100
101 echo "Starting afsd"
102 $AFSD $OPTIONS
103
104 #
105 # Run package to update the disk
106 #
107 if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
108         /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
109 case $? in
110 0)
111         (echo "Package completed successfully") > /dev/console 2>&1
112         date > /dev/console 2>&1
113         ;;
114 4)
115         (echo "Rebooting to restart system") > /dev/console 2>&1
116         sync
117         /sbin/reboot
118         ;;
119 *)
120         (echo "Package update failed; continuing") > /dev/console 2>&1
121         ;;
122 esac
123
124 fi
125
126 #
127 # Start AFS inetd services
128 # (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
129 #
130 if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
131         /usr/sbin/inetd.afs /etc/inetd.conf.afs
132 fi