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