afsio is a command to pipe data into or out of afs files
[openafs.git] / src / platform / DARWIN / AFSPreference / start_afs.sh
1 #!/bin/sh
2
3 # start_afs.sh
4
5 #
6 # Created by Claudio Bisegni on 24/06/07.
7 # Copyright 2007 INFN. All rights reserved.
8 #
9 # Portions Copyright (c) 2003 Apple Computer, Inc.
10 #
11 # Updated to match standard service scripts
12 # Phil Holland <hollandp@umich.edu>
13
14 . /etc/rc.common
15
16 CheckForNetwork
17
18 VICEETC=$1/etc
19 AFSD=$2
20
21 CONFIG=$VICEETC/config
22 AFSDOPT=$CONFIG/afsd.options
23 PACKAGE=$CONFIG/package.options
24 VERBOSE=
25 if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi
26 if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi
27
28
29 if [ -f $CONFIG/afs.conf ]; then
30     . $CONFIG/afs.conf
31 fi
32
33 # Check this file second so that if users have altered the file, it will
34 # override the default options
35 if [ -f $AFSDOPT ]; then
36     OPTIONS=`cat $AFSDOPT`
37 fi
38         
39         echo "Starting OpenAFS"
40
41     if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
42                 AFSD_OPTIONS="$VERBOSE"
43     else
44                 AFSD_OPTIONS="$OPTIONS $VERBOSE"
45     fi
46
47     if [ "${NETWORKUP}" = "-NO-" ]; then
48         echo $AFSD_OPTIONS | grep -e '-dynroot' || exit
49     fi
50
51 # Need the commands ps, awk, kill, sleep
52     PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
53
54     if [ -d $VICEETC/afs.kext ]; then
55         echo "Loading AFS kernel extensions"
56         kextload $VICEETC/afs.kext
57     else
58         echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
59         exit 1
60     fi
61
62     if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
63         :
64     else
65         echo  "AFS kernel extensions failed to initialize. Skipping AFS startup."
66         exit 1
67     fi
68
69 #
70 # Check that all of the client configuration files exist
71 #
72
73     for file in $AFSD $VICEETC/cacheinfo \
74         $VICEETC/ThisCell $VICEETC/CellServDB
75       do
76       if [ ! -f ${file} ]; then
77           echo "${file} does not exist. Not starting AFS client."
78           exit 1
79       fi
80     done
81
82 #
83 # Check that the root directory for AFS (/afs) 
84 # and the cache directory (/usr/vice/cache) both exist
85 #
86
87     for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
88       do
89       if [ ! -d ${dir} ]; then
90           echo "${dir} does not exist. Not starting AFS client."
91           exit 2
92       fi
93     done
94
95     echo "Starting afsd"
96     $AFSD $AFSD_OPTIONS
97
98 #
99 # From /var/db/openafs/etc/config/afs.conf, call a post-init function or
100 # command if it's been defined
101 #
102     $AFS_POST_INIT
103
104 #
105 # Call afssettings (if it exists) to set customizable parameters
106 #
107     if [ -x $CONFIG/afssettings ]; then
108         sleep 2
109         $CONFIG/afssettings
110     fi
111